Hello,

I am using the following function to mixin in classes into specific object 
instances (this is adapted from python-list written py J.Jacob 
"new-style-classes-mixin", Fri Aug 9 14:05:41 CEST 2002):

***************************************************************************
def doMixin(targetInstance, extraClass):
    """
    Mixin new style classes see thread python tutor list, 
    appends the given name                                                      
                   onto the class name
    """
    class NewClass(extraClass,targetInstance.__class__): pass
      
NewClass.__name__=targetInstance.__class__.__name__+"_"+extraClass.__name__
    targetInstance.__class__=NewClass
    try:
        extraClass.initialize(targetInstance)
    except AttributeError:
        pass
***************************************************************************

Is there an analogous way to "Mixout" classes from an instance at runtime?

Thank you,
Tomaz


      
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to