[Python-Dev] Re: decorators and 2.4 (original) (raw)

Martin Zarate mzarate at uoguelph.ca
Fri Jul 9 23:04:27 CEST 2004


I'm not sure if I should be writing this, I apologise in advanced if I'm wasting anyone's time - I've read over all of the arguments on decorators (last time I posted on the subject I hadn't, and I apologise for that as well).

I know Guido wants no new concepts of syntax, but it seems that all the concepts have merit - so why not a little synergy? Best of both worlds?

first complaint: @ is currently used in many projects, and is an ugly character.

second complaint:

[descriptors] def blah blah blah: is currently valid Python, and looks like valid Python, so it will confuse people.

third complaint: many suggestions are ungreppable.

So, a solution, mixing them all so that it becomes more than a simple list declaration:

as [descriptors] def blah blah blah:

or, an alternate, simply using the "as" keyword in the place of Guido's Java- style "@" character.

as descriptor1 as descriptor2 def blah blah blah:

Both of these are far more unique than other suggested blocks of code (like the [] header), allowing easier grepping and syntax highlighting, without having to go using the @ character that a) takes up one of the few unused Python special characters and b) breaks compatibility with some external processor programs.

IIRC, the "as" keyword became a protected keyword in recent versions, did it not? So it doesn't break anything to convert into a full keyword. It also makes syntactic sense, as you read "as staticmethod define myfunction" or "as functor(member1, member2, member3) define myfunction" when you read aloud.
It makes sense, keeping Python code legible and friendly.

In my personal tastes, I'd prefer the "as" keywords to go below the function header before the docstring, but I see that most others disagree.

Anyhow, my suggestion is a little more verbose, but I find it very legible and sensible (and given how Python is often used as a learning language, those features should be near the forefront). I hope I haven't wasted anyone's time.

-- Martin Z.



More information about the Python-Dev mailing list