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

Dan Schmidt dfan at dfan.org
Sun Jan 12 19:36:42 EST 2003


jbperez808 at yahoo.com (Jonathan P.) writes:

| 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.
| 
| I was thinking of using '_' ('I' is a distant second
| choice) instead of self.  Comments?

I used to use _, but I decided to be a good citizen and use self these
days.  My main problem with self is not that it takes more time to
type but that it looks like just another word when I'm scanning code,
which distracts me from the 'real' variables.  So I modifed my emacs
python-mode so that self is displayed in a different color, and I can
deal with it a lot better now.

Dan

-- 
http://www.dfan.org




More information about the Python-list mailing list