Is types.InstanceType no longer valid with Python 2.2
Alex Martelli
aleax at aleax.it
Fri Jan 4 12:09:12 EST 2002
"Georg Lohrer" <GeorgLohrer at gmx.de> wrote in message
news:43293uk34r6dgn5vgel7j0uiekhg6jp0no at 4ax.com...
...
> If the passed variable is an instance of a class, the __dict__ entries
> will be examined by calling the algorithm again. Lists and
> dictionaries have to be handled in a different manner.
So what do you want to do if the passed variable is an instance of
a class (with its own __dict__ or __slots__) AND is a list or dictionary
too?
class fooledyou(list):
def __init__(self, *any):
list.__init__(self, *any)
self.also = 'an attribute'
This is Python 2.2, and indeed the key improvement out of all the
many ones that are in 2.2 over 2.1. "Being a class's instance",
"having a __dict__", and "being a list" (or dict) are not mutually
exclusive any more.
So, you probably need to re-think your approach.
Alex
More information about the Python-list
mailing list