[Python-ideas] PEP: Shorthand Symbol for "self"
Scott Dial
scott+python-ideas at scottdial.com
Wed Aug 27 19:54:19 CEST 2008
Russ Paielli wrote:
> Normally I agree with you on the single-character identifiers, but I
> consider this case an exception. Lets not forget that C++ and Java use
> zero-character identifiers for "self", and I don't hear a din of
> complaints that it harms readability.
(Not) from who? I think in general Pythonistas complain that the
"zero-character identifiers" harm readability. Someone already said this
in this thread:
Andy Toulouse wrote:
> I don't like programming in languages that don't make as clear a
> distinction between local variables and instance variables.
In the rare cases that I am writing Java or C++ these days, I absolutely
use "this" explicitly despite the lack of a requirement to do so. It's
simply more readable in the long-term.
> My code does not appear to me to be any less readable to me when I
> substitute "S" for "self". The fact that it is a capital letter helps a
> bit here, I think. The fact that it usually appears as "S.attr" rather
> than just "S" also makes it stand out clearly.
>
> I just don't see the problem with having an "approved" shorthand form
> for self when it does not require any changes in the language itself.
Feel free to write code like this for yourself. I don't see anyone
"approving" any sort of "shorthand form" ever. The only official stance
on coding conventions is intended to guide the writing of code for the
stdlib. I find it very unlikely anyone would accept "S" in place of
"self" within the stdlib. Furthermore, I think the likelihood of having
another developer working with your code will sharply go down if you
stray from the guidelines for the stdlib. But to paraphrase what someone
else in this thread already said: what you do in private is your business.
-Scott
P.S. Top-posting is inappropriate for this list and makes it more
difficult to follow long discussions (like this one).
--
Scott Dial
scott at scottdial.com
scodial at cs.indiana.edu
More information about the Python-ideas
mailing list