[Python-Dev] method decorators (PEP 318)

Peter Otten Peter.Otten at t-online.de
Fri Mar 26 17:05:49 EST 2004


Yet another variant that deals with "passive" metadata - make the first 
dictionary special just like the first string.

>>> def foobar():
...     { author = "van Rossum",
...       deprecated = True }
...
>>> foobar.deprecated
True

Even better, stash it all away in a another attribute:

>>> foobar.__meta__
{"author": "van Rossum", "deprecated": "not yet"}

This would work for functions, classes and modules alike. Fitting in nicely: 
the alternative spelling for all dictionaries.

{alpha="value", beta="another value"}

Peter Otten





More information about the Python-Dev mailing list