Changing the class of an instance

Moshe Zadka moshez at math.huji.ac.il
Wed Jul 12 13:48:23 EDT 2000


On 12 Jul 2000, Richard Tobin wrote:

> Is it legal (it seems to work) to change the class of an object by
> assigning to its __class__ attribute?  In particular for the case where
> the new class is a subclass of the old.
> 
> I'm not looking for an argument (not even the five minute one) about
> whether it's a good idea, just whether it's legal.

Well, you can't get arrested for it in Britain, AFAIK. However, accidents
have happened to people who did this, so I'd be careful if I were you.

--
Moshe Zadka <moshez at math.huji.ac.il>
There is no GOD but Python, and HTTP is its prophet.
http://advogato.org/person/moshez





More information about the Python-list mailing list