Is types.InstanceType no longer valid with Python 2.2
Georg Lohrer
GeorgLohrer at gmx.de
Sat Jan 5 08:29:34 EST 2002
More information about the Python-list mailing list
Sat Jan 5 08:29:34 EST 2002
- Previous message (by thread): Is types.InstanceType no longer valid with Python 2.2
- Next message (by thread): Starship / PSA
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, 4 Jan 2002 18:09:12 +0100, "Alex Martelli" <aleax at aleax.it> wrote: >"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. After having a look at the code you mentioned, their seems no way to differ between instances of class-objects and all other built-in types using something like the already mentioned types.InstanceType. So, I really have to change the algorithm and check for other indicators than to that one. Thank you and all the others for information, Ciao, Georg
- Previous message (by thread): Is types.InstanceType no longer valid with Python 2.2
- Next message (by thread): Starship / PSA
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list