I have a class that’s being imported in module_x for instantiation, but first I want to override one of the class’s methods to include a specific feature dynamically (inside some middleware that runs before module_x is loaded.
I have a class that’s being imported in module_x for instantiation, but first I
Share
Neither AndiDog’s nor Andrew’s answer answer your question completely. But they have given the most important tools to be able to solve your problem (+1 to both). I will be using one of their suggestions in my answer:
You will need 3 files:
File 1: myClass.py
File 2: importer.py
File 3: module_x.py
The output of module_x would print “I like pi”
Hope this helps