[Python-ideas] PEP: Shorthand Symbol for "self"

Brett Cannon brett at python.org
Mon Aug 25 01:53:15 CEST 2008


On Sun, Aug 24, 2008 at 3:43 PM, Russ Paielli <russ.paielli at gmail.com> wrote:
> Hello,
>
> I have written a PEP, and I was warned by none other than Mr. Van Rossum
> himself that it would be controversial at best. Well, here goes anyway.
>
> First, let me introduce myself. I am an aerospace engineer, and I am using
> Python to develop a research prototype of a conflict alerting aid for air
> traffic controllers. It is intended to replace the current legacy system
> which has been operational since the 1970s. I have also developed a free
> Python package to represent physical scalars in a unique manner that can be
> as efficient as built-in numeric types. I am using it extensively in my
> conflict alerting aid. You can read about it in the current edition of The
> Python Papers at http://pythonpapers.org or on my website at
> http://RussP.us/scalar.htm .
>
> Now to the PEP. Let me start by saying that I fully understand the history
> and controversy regarding the explicit use of "self" in Python. I am not
> going to say that it was a mistake, nor am I going to say that the first
> argument of a class instance method should not refer to the instance for
> which it is called. What I will say is that I think Python syntax could be
> significantly simplified with the simple little convention that I am
> proposing. All I ask is that you carefully read my proposal before you
> reply. Thank you.
>

Couple things. One, tilde and carat are not even possible options as
they are used for binary negation and XOR, respectively.

Two, I disagree that it is in any way difficult to remember what the
first argument is since everyone names it either 'self' or 'cls'
depending on whether it is a classmethod or not.

Three, I don't see how a bunch of dollar signs in code is not just as
much clutter as 'self.'. Sure, it's shorter by four characters, but
that is not much in the grand scheme of things.

Four, I just think it's ugly to have a dollar sign prepend a name like that.

And five, the dollar sign is distracting. My eye automatically
gravitates to non-letter and non-digit characters, and having the code
littered with '$' is going to be distracting, IMO.

Thanks for trying, Russ, but this gets a -1 from me.

-Brett



More information about the Python-ideas mailing list