Need advice on subclassing code

wittempj@hotmail.com martin.witte at gmail.com
Tue Nov 15 11:02:45 EST 2005


Would the approach of using a switch to decide to instatite which class
good for you, like:

py> class C:
py.     name = 'C'
py.
py> class D:
py.     name = 'D'
py.
py> switch = { (1, 1): C, (1,2): D }
py> x = 1
py> y = 2
py> c = switch[(x,y)]()
py> print c.name
D
py>




More information about the Python-list mailing list