0

Why self everywhere?! Are we joking?

I come here to have a look at this "Uber simple and powerful python, you nee to try it this is the future"...coming from C++ I find this python lighter and simple...but "self" keyword ..."self" is similar to "*this" (note "this" is a pointer in C++).... Why in every members someone need to call self every time??? Why in 2018 nobody lock it as a language private word and make it accessible to member definition just by calling it??

16th Oct 2018, 5:35 PM
Alberto Simeoni
Alberto Simeoni - avatar
3 Respostas
16th Oct 2018, 7:01 PM
Ahri Fox
Ahri Fox - avatar
+ 3
The only time I ever use self is when generating an object in a class, and that's useful for differentiating between local variables and assigning a variable to the object. But maybe I misunderstand you; I don't use classes often, and I don't know C++. I prefer a more functional approach than object oriented.
16th Oct 2018, 6:03 PM
Ahri Fox
Ahri Fox - avatar
0
In C++ you don't need to define self every time...something like (example) (python) Def: member(self) self.something() (C++) Void member() { this->something(); } I think due to the simplicity of python: Why "self" need to be always declared and can not be implicit, even in a strongly typed language like C++ a similar construct ("this" ) is implicitly called, why self is not a language reserved word?? There should be a good reason no why?
16th Oct 2018, 6:28 PM
Alberto Simeoni
Alberto Simeoni - avatar