Decorator syntax
Sean Ross
sross at connectmail.carleton.ca
Sat Aug 7 09:37:41 EDT 2004
"Anthony Baxter" <anthonybaxter at gmail.com> wrote in message
news:mailman.1335.1091875631.5135.python-list at python.org...
> On Sat, 07 Aug 2004 16:28:11 +0600, Yawar Amin <yawar.amin at gmail.com>
wrote:
> > How about
> >
> > def foo(a, b, c):
> > foo.accepts = (int, int, list)
> > foo.author = 'Chris King'
>
> How would you express foo=classmethod(foo) in this syntax? Far better to
have
> one flexible tool in the toolbox than a host of little, less functional
tools.
Well, You could add a decorate method with the following signature to
functions:
func.decorate(*decorators, **attributes)
Then use:
def foo(a, b, c):
"foo can decorate itself, from the inside"
foo.decorate(abstract, synchronized, classmethod,
accepts=(int,int,int), author='Chris King')
...
...
More information about the Python-list
mailing list