Return to Snippet

Revision: 17724
at September 12, 2009 17:05 by manatlan


Initial Code
class Slave1(object):
    t1="1"
class Slave2(object):
    t2="2"

class MetaClass(type):
    def __new__(meta, classname, bases, classDict):
        bases = tuple([Slave1, Slave2])
        return type.__new__(meta, classname, bases, classDict)

class Master(object):
    __metaclass__ = MetaClass

m=Master()
print m.t1
print m.t2

Initial URL

                                

Initial Description

                                

Initial Title
inherit dynamically from multiple class

Initial Tags
python

Initial Language
Python