[Python-Dev] Re: Plea for simpler decorator syntax, in addition to pie-shaped syntax (original) (raw)
Tim Peters tim.peters at gmail.com
Thu Aug 5 21:40:05 CEST 2004
- Previous message: [Python-Dev] Re: Plea for simpler decorator syntax, in addition to pie-shaped syntax
- Next message: [Python-Dev] Re: 2.4a2, and @decorators
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[Gustavo Niemeyer]
IMO, the most common uses of decorators will be to define properties, and class and static methods. IMO, these uses would be better served by a simpler syntax:
def classmethod foo(cls, ...): ...
I've seen this example several times today, and I have to say that every time I've seen it, my unstoppable gut reaction was "wait, why are they defining their own classmethod function here?!". I've had that problem since the first time this syntax vairant was suggested (loooooong ago), and it's not going away. Maybe it's 10+ years of "in Python, the name of the function comes after the 'def'" and I just can't adjust that to qualify "but is the last name after a 'def' preceding the first left paren following the 'def'"; or maybe it's because I've written God-only-knows how many tools that believe the same thing (the Emacs python-mode parser; the IDLE parser; any number of one-shot cheap-ass regexps). Whatever, I can't get used to it.
So, sorry, but I like
@classmethod def foo(cls, ...):
unboundedly better than that. For that matter, I like it at least as well as any alternative to date, and better than most. I actively hate putting stuff between 'the def' and the function name.
Then again, I'm old .
- Previous message: [Python-Dev] Re: Plea for simpler decorator syntax, in addition to pie-shaped syntax
- Next message: [Python-Dev] Re: 2.4a2, and @decorators
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]