Play with classes

Zunbeltz Izaola zunbeltz at wm.lc.ehu.es.XXX
Thu Feb 26 05:28:33 EST 2004


Hi to all!

I wonder if it possible (i'm sure python can do :-) ) to define classes on
runtime. My problem (schematically) is the folowwin.

The User can choise betwenn 3 property of an object.

Mode, Type and Subtype.

I have the following classes defined

ModeA, ModeB, TypeA, TypeB, TypeC, SubtypeA, SubtypeB.

Supose the user whant to combine ModeA with TypeB and SubtypeB, so I need
something like

class UserClass(ModeA, TypeB, SubtypeB):
        pass

I can define all the posibilitys different classes and the using nested
if/else I can use the correct class, but I want to know if there is a way 
generate in the fly and in this way there is no necesarity to change code whe
new Modes or Types are created.

I hope it is clear enough :-)

Thanks in advance

Zunbeltz



More information about the Python-list mailing list