self

Tim Peters tim.one at comcast.net
Tue Jun 4 12:28:38 EDT 2002


[Vojin Jovanovic]
> 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++?

...
class C:
    ...
    def vojin(self):
        i = j + k

Which of i, j and k are instance variables?  Which are locals?  Which are
globals?  For all its virtues, Python isn't telepathic <wink>.






More information about the Python-list mailing list