Is it advisable to replace 'self' with '_' or 'I' or something shorter?

Erik Max Francis max at alcyone.com
Tue Jan 21 20:51:02 EST 2003


Carl Banks wrote:

> But I always thought "self" was one of those conventions it's best not
> to stray from.

Indeed.  In any programming language, it's always advisable to follow
the coding style that's being used in the code you're editing,
regardless of what that style is (if you don't like the style,
convincing others to change is better than just being maverick).

The use of the identifier `self' for that "self" argument is so
pervasive (see?  We even call it the "self" argument) that it's almost a
perversion to use something else.

Temporarily binding shorter names to long things for convenience is one
thing, and is commendable when appropriate, but seeing anything other
than `self' as the first argument in a standard method is a crime
against nature :-).

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ Ride / Ride this wave of mine
\__/ Res
    Physics reference / http://www.alcyone.com/max/reference/physics/
 A physics reference.




More information about the Python-list mailing list