python decorator arguments with @ syntax
问题 I'm trying to use a cached property decorator that can take arguments. I looked at this implementation: http://www.daniweb.com/software-development/python/code/217241/a-cached-property-decorator from functools import update_wrapper def cachedProperty (func ,name =None ): if name is None : name =func .__name__ def _get (self ): try : return self .__dict__ [name ] except KeyError : value =func (self ) self .__dict__ [name ]=value return value update_wrapper (_get ,func ) def _del (self ): self