[Python-Dev] Re: decorators and 2.4
Guido van Rossum
guido at python.org
Wed Jun 23 00:36:00 EDT 2004
> Guido is undecided on the syntax - he writes "I'm seriously
> considering doing it Java-style", but adds that he is totally
> swamped for the next two weeks. He finishes with:
> "Feel free to suggest this as a project for an adventurous
> python-dev'er though."
>
> So, who's feeling adventurous? I'm convinced that this should go
> into 2.4 if possible, and I don't think there's any _technical_
> risks (as far as implementation goes), the only problem is the
> syntax (and yes, that's a technical problem too, but you know
> what I mean).
>
> Channelling Guido, via his EP keynote
> (http://www.python.org/doc/essays/ppt/euro2004/euro2004.ppt)
> I'm assuming that "Java-style" is something like:
>
> @staticmethod
> def blah(args):
> body
>
> @funcattrs(vegetable="blah", author="GvR")
> def blah2(args):
> body
Right on both counts.
> It's not clear to me how you'd specify multiple decorators this
> way, perhaps Guido can give more details...
Easy:
@staticmethod
@funcattrs(vegetable="blag", author="GvR")
def blah2(args):
body
I would love to see an implementation of this idea.
One advantage mentioned by Fredrik Lundh of this, and also of my other
favorite, over "decorators-after-args" is that the decorators are
easily cut-and-pasted -- it's much easier to cut whole lines than
sections of a line, and cutting a multiple-lines-spanning section is
even worse.
If people prefer my favorite (decorator-list-before-def, C# style)
over Java-style, that's fine too... :-)
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev
mailing list