[Python-bugs-list] [ python-Bugs-712975 ] Cannot change the class of a list

SourceForge.net noreply@sourceforge.net
Tue, 01 Apr 2003 02:30:05 -0800


Bugs item #712975, was opened at 2003-03-31 23:00
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=712975&group_id=5470

Category: Type/class unification
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Jiba (jiba)
>Assigned to: Guido van Rossum (gvanrossum)
Summary: Cannot change the class of a list

Initial Comment:
The class of list (or dict) can no longer be changed in
Python 2.3a2 ; this was possible with Python 2.2.2 (as
long as the new class extend list and has no slot).
When doing so ([].__class__ = ...), i get this error :

TypeError: __class__ assignment: only for heap types


Not being able to change the class of non-mutable
object (e.g. int, float or tuple) is AMHO not a great
loss, but list and dict ARE mutable, and so changing
their class does have a sens !

Typically it can be used to observed a list that you
have not created yourself (see atteched script); i was
relying a lot on such observation features.

----------------------------------------------------------------------

>Comment By: Michael Hudson (mwh)
Date: 2003-04-01 11:30

Message:
Logged In: YES 
user_id=6656

IMHO, changing the class of an immutable object is, was and
always will be Right Out.

Changing the class of a mutable is dicier.  I personally
don't think it's worth the effort, but assigning to Guido
for pronouncement.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=712975&group_id=5470