Why self?

Robb Shecter rs at onsitetech.com
Mon Jul 8 13:42:00 EDT 2002


Matt Gerrans wrote:

> In Python, I think the required "self" reference in methods is a case where
> the solution is worse than the problem it solves.   Since indentation is the
> method of scoping in Python, this addition of five characters to each
> instance variable is particularly annoying -- a one-line statement that
> contains several instance variables can easily become unmanageable.

I completely agree, but I think the situation's even worse than you 
described:  A'typical' case of standard OO programming is made the most 
tedious to write:  References to instance variables from methods:

     self.__velocity = self.__factor1 * self.__factor2

etc.  I find this totally unreadable (7 extra characters per referenced 
instance variable).

Robb




More information about the Python-list mailing list