Changing the class of an instance

Paul Prescod paul at prescod.net
Wed Jul 12 13:54:27 EDT 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.

It language reference doesn't say. I think you're on your own but I
wouldn't expect it to break soon. I also wouldn't expect it to work in
JPython or maybe even Zope.

-- 
 Paul Prescod - Not encumbered by corporate consensus
Simplicity does not precede complexity, but follows it. 
	- http://www.cs.yale.edu/~perlis-alan/quotes.html






More information about the Python-list mailing list