Is it possible to check if a function has been decorated with a listener?
Posted: Wed Oct 05, 2016 10:46 am
For example, is it possible to know from my_listener that it has been decorated here:
I'm using a class decorator and I need to loop through all of the class's methods, and if they have been decorated with a listener, I need to wrap them. Basically this:But I need a proper check for the is_decorated
Edit: Nvm, I can just use isinstance() check for ListenerManagerDecorator
Syntax: Select all
@OnLevelChange
def my_listener(...):
pass
I'm using a class decorator and I need to loop through all of the class's methods, and if they have been decorated with a listener, I need to wrap them. Basically this:
Syntax: Select all
for attr in dir(cls):
func = getattr(cls, attr)
if is_decorated(func):
setattr(cls, attr, wrapped(func))
Edit: Nvm, I can just use isinstance() check for ListenerManagerDecorator