I’m looking at modifying the behavior of some 3rd party Python code. There are many classes derived from a base class and in order to easily achieve my goal, it’d be easiest just to override the base class used to derive all the other classes. Is there a simple way to do this without having to touch any of the 3rd party code? In case I’ve failed to clearly explain this:
class Base(object):
'...'
class One(Base)
'...'
class Two(Base)
'...'
…I wold like to make modifications to Base without actually modifying the above code. Perhaps something like:
# ...code to modify Base somehow...
import third_party_code
# ...my own code
Python probably has some lovely built-in solution to this problem, but I’m not yet aware of it.
Perhaps you could monkey-patch the methods into
Base?This prints out