Dynamically add a decorator to class
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Realization
--
Chapters
00:00 Question
03:12 Accepted answer (Score 10)
03:44 Thank you
--
Full question
https://stackoverflow.com/questions/1595...
Question links:
[decorator to debug PyQt signals]: https://gist.github.com/durden/5367247
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #pyqt #pyqt4 #decorator #pythondecorators
#avk47
    --
Music by Eric Matyas
https://www.soundimage.org
Track title: Realization
--
Chapters
00:00 Question
03:12 Accepted answer (Score 10)
03:44 Thank you
--
Full question
https://stackoverflow.com/questions/1595...
Question links:
[decorator to debug PyQt signals]: https://gist.github.com/durden/5367247
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #pyqt #pyqt4 #decorator #pythondecorators
#avk47
ACCEPTED ANSWER
Score 10
Decorators are nothing more than callables that are applied automatically. To apply it manually, replace the class with the return value of the decorator:
import somemodule
somemodule.someclass = debug_signals(somemodule.someclass)
This replaces the somemodule.someclass name with the return value of debug_signals, which we passed the original somemodule.someclass class.