Guido's new method definition idea

Russ P. Russ.Paielli at gmail.com
Sat Dec 6 17:01:40 CET 2008


On Dec 6, 7:34 am, Steven D'Aprano <st... at REMOVE-THIS-
cybersource.com.au> wrote:
> On Sat, 06 Dec 2008 07:15:27 -0800, Russ P. wrote:
> > On Dec 6, 4:32 am, Andreas Waldenburger <geekm... at usenot.de> wrote:
> >> On Sat, 6 Dec 2008 04:02:54 -0800 (PST) bearophileH... at lycos.com wrote:
>
> >> > class C:
> >> >     def $method(arg):
> >> >         $value = arg
>
> >> > (Note there's no point after $, it's not currently possible).
>
> If -- and that's a HUGE if -- the compiler is changed to allow $method,
> it could certainly be changed to allow $.method.
>
> >> > Ruby
> >> > uses @ and @@ for similar purposes. I agree that the code looks
> >> > worse, but also shorter to read and write, so in lines of code that
> >> > use many instance attributes, that short $ syntax helps keep the line
> >> > shorter. So I may grow to accept this sugar...
>
> If a line of code uses too many instance attributes to fit comfortably on
> a line, spread it over two lines. There is no newline shortage, they are
> a renewable resource.
>
> >> But that is not the way Python is meant to work. There are several
> >> tennets in the Zen of Python that don't chime well with this approach.
> >> "self" is a speaking identifier, "$" isn't.
>
> > Is "@" a "speaking identifier? How about "#" and "!="? Last I heard,
> > they were all part of Python.
>
> Yes they are.
>
> @f
>
> is pronounced "at f" or "decorate f".
>
> # comment
>
> is pronounced "hash comment" or even not pronounced at all.
>
> x != y
>
> is pronounced "x not equal to y"
>
> The proposed
>
> def $method(arg):
>
> would be pronounced "def dollar method arg" or "def method self arg". The
> first is ugly to my ears, the second confusing.

Regarding "$" as a stand-in for "self" is less of a stretch than the
examples you gave.

> -2 on this proposal.

Did you get two votes in the Presidential election too? 8^)




More information about the Python-list mailing list