Posted By

manatlan on 09/12/09


Tagged

python tech


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

gartenstuhl


inherit dynamically from multiple class


 / Published in: Python
 

  1. class Slave1(object):
  2. t1="1"
  3. class Slave2(object):
  4. t2="2"
  5.  
  6. class MetaClass(type):
  7. def __new__(meta, classname, bases, classDict):
  8. bases = tuple([Slave1, Slave2])
  9. return type.__new__(meta, classname, bases, classDict)
  10.  
  11. class Master(object):
  12. __metaclass__ = MetaClass
  13.  
  14. m=Master()
  15. print m.t1
  16. print m.t2

Report this snippet  

You need to login to post a comment.