Why self?

Robb Shecter rs at onsitetech.com
Mon Jul 8 14:41:18 EDT 2002


An even more unreadable example is the coding I had to do in a class 
that sovled a linear equation and uses the computed values:

         return self.__m * aNumber + self.__b

I'm doing y = mx + b here, and do the variable names 'm' and 'b' are 
completely reasonable.  And here, it's not just the fact that there's 7 
extra characters, but that the variable names are now 7 times longer 
than they could be:

         return m * aNumber + b

Robb




More information about the Python-list mailing list