Function metadata (like Java annotations) in Python

fumanchu fumanchu at amor.org
Sun Sep 10 00:25:28 EDT 2006


oripel wrote:
> I'm trying to attach some attributes to functions and methods, similar
> to Java annotations and .NET attributes.
> ...
> Assigning attributes to the function will work, as will assigning keys
> and values to a dictionary in an attribute. But if there are more
> decorators in the way, this could fail:
>
> @onedec
> @attr(...)
> @twodec
> def foo():
>   ...
>
> Given 'foo' now, how do I find the attributes?
> ...
> Any thoughts? Am I rehashing something old that my search skills didn't
> uncover?

There are past discussions about this; google for "python-dev decorator
metadata". For example:
http://thread.gmane.org/gmane.comp.python.devel/77506/focus=77507


Robert Brewer
System Architect
Amor Ministries
fumanchu at amor.org




More information about the Python-list mailing list