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

Kevin Altis altis at semi-retired.com
Sat Jan 11 19:23:27 CET 2003


The most common is probably 's'. However, it makes it more difficult for
other people to read your source if don't use 'self', so it isn't advisable.
You might consider binding a "macro" to type out "self." if typing the
characters bothers you or use some funky character that doesn't occur in
your source and do a global replace later on, but that is probably
error-prone.

ka

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






More information about the Python-list mailing list