On Wed, Dec 17, 2008 at 6:41 AM, psaff...@googlemail.com <psaff...@googlemail.com> wrote: > This might be a pure OO question, but I'm doing it in Python so I'll > ask here. > <snip> > > The problem is that IDPointSet and MicroArrayPointSet will need to > inherit from PointSet or TraceablePointSet based on whether I'm > handling traceable points or not. Can I select a superclass > conditionally like this in Python? Am I trying to do something really > evil here?
You're doing something really dynamic; don't think I'd call it inherently evil though. All you have to do is use a variable in the inheritance syntax, it's really quite simple: superclass = TraceablePointSet if tracing else PointSet class IDPointSet(superclass): #body code here #use same trick for MicroArrayPointSet Cheers, Chris -- Follow the path of the Iguana... http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list