assignment to __class__ (was Re: Copy constructors)
Guido van Rossum
guido at python.org
Mon Aug 13 23:54:03 EDT 2001
[Alex]
> > I thought I had understood it, but still don't see where it mentions
> > "x.__class__ = whatever" now being forbidden or restricted?
[Terry]
> I rechecked. It does not. Did find "For instance of built-in
> types, x.__class__ is now the same as type(x): " which does hint
> that it might be problematical for subtypes.
>
> Is the proposed restriction for subtype insstances only or also for
> subclass instances?
If you mean the distinction between "classic classes" and new-style
classes (those derived from 'object' or using an explicit metaclass),
the restriction does not apply to classic classes. Classic classes
don't change in 2.2 -- they are slated for change much later (around
3.0).
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-list
mailing list