self

Gerhard Häring gerhard at bigfoot.de
Tue Jun 4 18:27:53 CEST 2002


Vojin Jovanovic wrote:
> I have been working on a project trying to implement some advanced
> functionality.  Now, one thing that has been a constraint for me is the
> concept of self.  Why is it that within a class one has to use self. (or
> "any word". ) to refer to instance variables? Would it not be more logical
> to just use the name of the variable like it is for example in C++?
 
It's good practice in C++ and Java too, to always use this->myvar resp.
this.myvar.

I hate to have to look at code where the scope of the variable isn't obvious at
once. And I also hate conventions like m_mymembervar to distinguish members
from locals.

Gerhard



More information about the Python-list mailing list