>>> class Classless(object):
... def __getattr__(self, name): raise AttributeError(name)
...
>>> Classless().__class__
<class '__main__.Classless'>
>>> c = Classless()
>>> c.__class__ = None
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: __class__ must be set to new-style class, not 'NoneType' object
Yeah, this was super interesting to me.
ReplyDeletehttp://bugs.python.org/issue12099