@decorator syntax is sugar, but for what exactly? (decorator libraries).

Andrew Durdin adurdin at gmail.com
Sun Aug 8 16:27:53 CEST 2004

On Sun, 08 Aug 2004 10:19:19 -0400, Roy Smith <roy at panix.com> wrote:
> The key question is whether the decorator mechanism would allow such a
> thing?  All of the examples I've seen have the decorator defined right
> before it's used, and having a simple name.  I'm guessing that the real
> syntax is @<callable>, and that any expression that evaluations to a
> callable object is kosher after the "@"?

There was some discussion about this on python-dev, and the BDFL's
conclusion was that arbitrary expressions were not allowed, but only
dotted names (with optional parentheses), i.e.:


(With presumably multiple dotted levels allowed, e.g. module.object.decorator)

See http://www.python.org/dev/doc/devel/ref/function.html for the
grammar definition.

More information about the Python-list mailing list