No need to evaluate func twice
def no_trespassing(func): def grass(lawn): res = func(lawn) if res is None: return 'No trespassing!' return res return grass @no_trespassing def get_of_my_lawn(on_my_lawn): if on_my_lawn is True: return 'get of my lawn'
- def no_trespassing(func):
- def grass(lawn):
- res = func(lawn)
- if res is None:
- return 'No trespassing!'
return func(lawn)- return res
- return grass
- @no_trespassing
- def get_of_my_lawn(on_my_lawn):
- if on_my_lawn is True:
- return 'get of my lawn'