converting base class instance to derived class instance

John Roth newsgroups at
Mon Feb 9 22:56:41 CET 2004

"François Pinard" <pinard at> wrote in message
news:mailman.1372.1076344361.12720.python-list at

>>> o.__class__ = C
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: __class__ assignment: only for heap types

By the way, what is a "heap type"?

I think they're refering to objects that are allocated
on the heap. I'm not sure what attempting to
instantiate object would do, but I suspect the result
would be a built-in that can't be modified.

John Roth

François Pinard

More information about the Python-list mailing list