Decorating function or method in python is wonderful.
@dec2
@dec1
def func(arg1, arg2, ...):
pass
#This is equivalent to:
def func(arg1, arg2, ...):
pass
func = dec2(dec1(func))
I was wondering if decorating variable in python is possible.
@capitalize
@strip
foo = ' foo '
print foo # 'FOO'
#This is equivalent to:
foo = foo.strip().upper()
I couldn't find anything on the subject via searching.