Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def method_friendly_decorator(method_to_decorate):
- def wrapper(self, lie):
- lie = lie - 3 # very friendly, decrease age even more :-)
- return method_to_decorate(self, lie)
- return wrapper
- class Laurel(object):
- def __init__(self):
- self.age = 32
- @method_friendly_decorator
- def sayYourAge(self, lie):
- print("I am {0}, what did you think?".format(self.age + lie))
- l = Laurel()
- l.sayYourAge(-3)
- #outputs: I am 26, what did you think?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement