[Python-Dev] method decorators (PEP 318)

Josiah Carlson jcarlson at uci.edu
Fri Mar 26 16:48:07 EST 2004


Personally, I believe discussion over PEP 318 has wandered from
an implementation and practical purity, into a syntactical nightmare.

We went from a single decorator syntax that worked for all kinds of
decorators, to another decorator syntax...that still works for all kinds
of decorators.  Wait, decorators haven't changed...but something else
has.

In addition to the proposed decorator syntax, now there is this other
syntax that seems to want to be attached to 318 (that Guido seems to
want to use '@', others have suggested '.' and ':' to signify), for
inserting metadata attributes into the function body.  This syntax
doesn't allow if, while, etc. statements, and really could be considered
a subset of Python.

I just read Mike Rovner's idea of allowing a dictionary in the body,
just before or after the docstring, to update the function's __dict__
attribute. If there existed an in-body metadata syntax, the dict literal
fits the current docstring syntax.

PEP 318 is about general function and class decorator syntax, which most
everyone has basically agreed upon (some list just before or after the
arguments), and this metadata-specific extension, I believe should be
its own PEP (regardless of which idea is favored, and regardless of
whether it is a good idea).


 - Josiah

P.S. If dict literals are the future syntax of metadata, should
functions get implicit __slots__ with a list literal, ignoring all
metadata updates with unlisted slots? <wink>




More information about the Python-Dev mailing list