dynamically extend classes
gmcm at hypernet.com
Sat Feb 19 22:14:01 CET 2000
Matt Wette wrote:
> Is there a way to dynamically extend classes in Python?
> I'd like to be able to have sitecustomize.py import a module
> and add methods to a class so that later, when anohter modules
> imports this module and uses the class it sees the added methods.
bases = innocent.Sucker.__bases__
innocent.Sucker.__bases__ = bases + (MyAddedMethods,)
print "Come on in, dear, the water's fine!"
More information about the Python-list