When where and how can i change the __class__ attr of an object in Python?

Posted by Juanjo Conti on Stack Overflow See other posts from Stack Overflow or by Juanjo Conti
Published on 2010-06-10T09:45:00Z Indexed on 2010/06/14 7:52 UTC
Read the original article Hit count: 299

Filed under:
|

I'd like to be able to do:

>>> class a(str):
...     pass
...
>>> b = a()
>>> b.__class__ = str
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __class__ assignment: only for heap types

© Stack Overflow or respective owner

Related posts about python

Related posts about python-datamodel