Attack a sacred Python Cow

Russ P. Russ.Paielli at gmail.com
Mon Jul 28 00:27:19 EDT 2008


On Jul 27, 6:21 pm, Terry Reedy <tjre... at udel.edu> wrote:
> Russ P. wrote:
> > On Jul 27, 12:39 pm, Bruno Desthuilliers
> > All I am suggesting is that the programmer have the option of
> > replacing "self.member" with simply ".member", since the word "self"
> > is arbitrary and unnecessary.
>
> I presume you are proposing the opposite also, that ".member" would
> internally be expanded to "self.member".
>
> As I said before, that, or something near like it (it is hard to exactly
> compare underspecified proposals) has be suggested and rejected, even if
> someone gave you not the exact reference.  For one thing, as Guido
> noted, a single . can be hard to see and easy to miss, depending on
> one's eyesight, environmental lighting, and exact display medium,
> including font.
>
> I suspect Guido's other reasons have been covered, but I do not want
> misquote him.  I will leave you to search the pydev list archives.
>
>  > Otherwise, everything would work *EXACTLY* the same as it does now.
>
> If I understand you, that would mean that .attribute would raise
> NameError: name 'self' is not defined
> if used anywhere where 'self' was not defined.

After thinking about this a bit more, let me try to be more specific.

Forget about the empty first argument and the "." for the first
argument. Just let the first argument be "self" or anything the
programmer chooses. No change there.

If access is needed to "self.var", let it be accessable as either
"self.var" or simply ".var". Ditto for "self.method()", which would be
accessible as ".method()".

In other words, wherever ".var" appears, let it be interpreted as
"<arg1>.var". If the first argument is "self", then it should be
equivalent to "self.var". If the first argument is "snafu", then
".var" should be equivalent to "snafu.var".

I can't think of any technical problem with this proposal, but I may
be overlooking something. If so, please let me know.

This proposal should be relatively easy to implement, and it would
reduce code clutter significantly. (I could probably write a pre-
processor to implement myself it in less than a day.)



More information about the Python-list mailing list