Why self?

Robb Shecter rs at onsitetech.com
Mon Jul 8 14:37:36 EDT 2002


Brian Quinlan wrote:

>>     self.__velocity = self.__factor1 * self.__factor2
>>

> 
> Two of those characters are your own fault (the underscores).

I don't think so:  As I understand it, the double underscores are 
necessary in order to for the class to function correctly if subclassed. 
  Without them, a subclass could inadvertently use/misuse/overwrite them.

These requirements remind me of C++ or Perl, where in order to do the 
correct thing, you have to go through extra work.  Or, conversely, the 
language encourages you to do the wrong thing.

Robb




More information about the Python-list mailing list