[Python-Dev] decorator support
Xavier Combelle
xavier.combelle at free.fr
Sat Sep 18 02:57:36 CEST 2004
>
> This could be used to define a decorator
>
> @copyfuncattrs
> def trace(f):
> def do_trace(*args):
> print "invoking", f.__name__, args
> return f(*args)
> return do_trace
I am quite new in Python, and I do my first suggestions. (One time
I should begin)
If there is a general agreement about what to do to wrap a decorator,
why no use the following syntax
@decorator
def trace(f):
def do_trace(*args):
print "invoking", f.__name__, args
return f(*args)
return do_trace
I would prefer it because it explain what the method do
instead of how it implement it.
Generally speaking, I believe the decarators should
be very expressive, just because even if it is not
a part of the language, it's a kind of new syntax.
For the same reason, Python should incorporate
just a reduce set of decorators.
More information about the Python-Dev
mailing list