Dynamically add a decorator to class
--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Breezy Bay
--
Chapters
00:00 Dynamically Add A Decorator To Class
02:10 Accepted Answer Score 10
02:31 Thank you
--
Full question
https://stackoverflow.com/questions/1595...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #pyqt #pyqt4 #decorator #pythondecorators
#avk47
    Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Breezy Bay
--
Chapters
00:00 Dynamically Add A Decorator To Class
02:10 Accepted Answer Score 10
02:31 Thank you
--
Full question
https://stackoverflow.com/questions/1595...
--
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.