Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> def decorator(func):
- ... def wrapper(arg):
- ... return func(arg)
- ... wrapper.__name__ = func.__name__
- ... wrapper.__dict__.update(func.__dict__)
- ... return wrapper
- ...
- >>> @decorator
- ... def foo(arg):
- ... print arg
- ... return arg
- ...
- >>> foo(1)
- 1
- 1
- >>> foo(1, 2)
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- TypeError: wrapper() takes exactly 1 argument (2 given)
- >>> foo.__name__
- 'foo'
- >>>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement