decorator question

Schüle Daniel uval at rz.uni-karlsruhe.de
Sun Jan 8 19:50:59 EST 2006


thx to all

now I understand how it works and why it should be done in this way
so it's possible to write more than only one declarator

 >>> def foo(f):
...     l = [1]
...     def method(*a,**kw):
...             f(l, *a, **kw)
...     return method
...
 >>> def bar(f):
...     l = [2]
...     def method(*a,**kw):
...             f(l, *a, **kw)
...     return method
...
 >>> @foo
... @bar
... def foobar(x,y,z):
...     print x
...     print y
...     print z
...
 >>> foobar(1)
[2]
[1]
1

x and y are already binded
by the way .. to l's lists are considered to be in closure?
Or what is the right denotation for them?
Can someone give me some pointers to the metaprogramming in Python?
links etc

Regards, Daniel




More information about the Python-list mailing list