Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from functools import wraps
- class Formatter(object):
- def cap(self):
- def cap_decorator(func):
- @wraps(func)
- def func_wrapper(value):
- return func(value).upper()
- return func_wrapper
- return cap_decorator
- formatter = Formatter()
- class Person(object):
- def __init__(self, name):
- self.name = name
- @formatter.cap()
- def sayHi(self):
- return self.name
- bob = Person('Bob')
- print bob.sayHi()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement