assignment to __class__ (was Re: Copy constructors)

Toby Dickenson tdickenson at devmail.geminidataloggers.co.uk
Mon Aug 13 11:43:39 EDT 2001


Guido van Rossum <guido at python.org> wrote:

>It would be relatively easy to allow __class__ assignment only if (a)
>the new class is a subclass of the old class, and (b) the size of the
>new instance is the same as the old instance.  Would this be sufficient?

class A(bases...):
    ....
 
class B(A):
    ....

class C(A):
    ....

Under this rule I could change class from A to B, and from A to C. Is
there an easy rule that allows changing from B to C too? Perhaps, only
if the object was originally created as an A?

(I think this would satisfy Alex's UI-Engine example)

Toby Dickenson
tdickenson at geminidataloggers.com



More information about the Python-list mailing list