Re: Need advice on subclassing code

2005-11-15 Thread Michael Spencer
Kent Johnson wrote: > Rusty Shackleford wrote: >> ... >> C_1_1 and C_1_2 share a common C ancestor, and in practice may be >> identical, but theoretically, could have the same function name with two >> different implementations underneath. >> >> ... > > How are you instantiating the correct class?

Re: Need advice on subclassing code

2005-11-15 Thread Kent Johnson
Rusty Shackleford wrote: > Hi -- > > We have some code that returns an object of a different class, depending > on some parameters. For example: > > if param x is 1 and y is 1, we make an object of class C_1_1. > if param x is 1 and y is 2, we make an object of class C_1_2. > > C_1_1 and C_1_2

Re: Need advice on subclassing code

2005-11-15 Thread bruno at modulix
Rusty Shackleford wrote: > Hi -- > > We have some code that returns an object of a different class, depending > on some parameters. For example: > > if param x is 1 and y is 1, we make an object of class C_1_1. > if param x is 1 and y is 2, we make an object of class C_1_2. > > C_1_1 and C_1_2

Re: Need advice on subclassing code

2005-11-15 Thread [EMAIL PROTECTED]
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> -- http://mail.python.org/ma