Dynamically Changing the Base Class

Adam C. adamc55 at gmail.com
Mon Jul 7 09:31:57 EDT 2008


We have a situation where we want a Swig-generated Python class to
have a different base (not object). It doesn't appear that we can
coerce Swig into generating the class we want at present (but we are
still enquiring).

Is it possible to dynamically change the base class to something else?
Initial experiments appear to show it is not:
-------------------------------- snip --------------------------------
>>> class Foo(object):
	pass

>>> class Foozle(object):
	pass

>>> Foozle.__bases__ = (Foo,)

Traceback (most recent call last):
  File "<pyshell#6>", line 1, in <module>
    Foozle.__bases__ = (Foo,)
TypeError: __bases__ assignment: 'Foo' deallocator differs from
'object'
-------------------------------- snip --------------------------------

Is there a solution I am missing?

Thanks in advance.



More information about the Python-list mailing list