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

Terry Reedy tjreedy at udel.edu
Sat Jan 11 14:09:02 EST 2003


"Jonathan P." <jbperez808 at yahoo.com> wrote in message
news:f57664b9.0301110959.5b1439da at posting.google.com...
> I agree with the fact that explicit use of self is good
> for code readability, however it tends to make code lines
> too long.  Since 'self' is just a convention, I wonder if
> people out there have tried replacing it with a one-character
> equivalent without encountering any problems.

How could there be?  (Rhetorical question)
>
> I was thinking of using '_' ('I' is a distant second
> choice) instead of self.  Comments?

I routinely use s and o for self and other in private code.  's.' is
very easy for me to type (although having 'self.' in a macro or paste
buffer might work as well).  The only problem I have had is a couple
of people jabbing at me when saying so publicly.  But I plan to
continue anyway.  Good luck.

Terry J. Reedy






More information about the Python-list mailing list