Skip to main content

Python 2.4 and new decorators

I always get excited when a new release of python is announced. There are always all sorts of goodies to play around with. One of things I've been following for a while is PEP 318 which provides an easier way to specify class methods / static methods / whatever other kind of method you want. Basically syntactic sugar for wrapping methods. I have to say that among the various proposals for exactly what the syntax should be, the "@decorator" syntax is my least favourite. The '@' character has a definite un-pythonic feel, rather it feels closer to perl or ruby. Having the decorator specified on the preceeding line also doesn't make sense to me...A decorator is part of the function declaration, so it should be on the same line. The pre- or post-argument [decorator,...] syntax really appeals to me, it puts the list of decorators on the same line as the function declaration, and it obviously something other than the list of arguments to the function. Other 2.4 goodies that appeal to me include some nifty keywords to the list sort method ("key" in particular) and generator expressions. Now if only the path module would make it into the standard python library... Just my humble python-user's opinion.

Comments