on-internet
← Community

Get attribute set on class 'property method'

Stack Overflow ·

I have this simple decorator which sets an attribute mark='marked' on the decorated method def mark(fn): @wraps(fn) def wrapper(*args, **kwargs): return fn(*args, **kwargs) setattr(wrapper, 'mark', 'marked') return wrapper I use it on a class property method like this class Car(object): @property @mark def move(self): return "move" Now since Car.move is a property method, how do I access the marked attribute I created? >>> c = Car() >>> getattr(c.move, 'mark') AttributeError: 'str' object has no attribute 'mark' The error makes sense since c.move invokes the __get__ method on the property desc

Comments

Sign in or sign up to comment and upvote.

No comments yet.