Andy
Posts: 28
Nickname: adn
Registered: Jul, 2004
|
|
Re: Playing with decorators
|
Posted: Aug 10, 2004 6:26 AM
|
|
This descriptor stuff is quite a brainfeck. But ...
Use the *arg_list and **arg_dict syntax.
def pre(pre_func, *arg_list, **arg_dict): def wrapped(func): pre_func(*arg_list, **arg) # Assuming your function to be decorated doesn't take # any arguments ... func() return wrapped
I'll let you figure out the post function.
Look at the documentation, it should make things a bit clearer. Look at the "4 PEP 318: Decorators for Functions, Methods and Classes" under "What's New in Python".
|
|