The footnotes one that page says:
[1] It is possible in some cases to change an object’s type, under
certain controlled conditions. It generally isn’t a good idea though,
since it can lead to some very strange behaviour if it is handled
incorrectly.
If you try to change the __class__
of f2 to list
:
f2.__class__ = list
A TypeError raised:
TypeError: __class__ assignment: only for heap types