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

Erik Max Francis max at
Mon Jan 13 11:53:12 CET 2003

"Jonathan P." wrote:

> One compromise I can think of would be to just use 'self'
> all the time and in the isolated cases where it would
> lead to unbearably long (and unreadable) lines, create an
> alias variable for the offending attribute.

_And_ always do that in local scope.  Already you see this done,
especially if you have to translate involved mathematical equations to
code; you use shorter versions of the names so the expressions don't
become enormous.  But in the parameter declaration, the self argument
should always be nothing other than `self'.

As others have pointed out, there are good, solid reasons for not using
`_' in any case -- it's used in internationalization, the Python
interactive interpreter uses it for the last calculated expression, etc.

 Erik Max Francis / max at /
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ Only the winners decide what were war crimes.
\__/ Gary Wills Counter-Strike /
 A personal guide to Counter-Strike.

More information about the Python-list mailing list