isinstance(obj, type(obj)) == True?
clp2 at rebertia.com
Wed Jun 24 13:22:39 EDT 2009
On Wed, Jun 24, 2009 at 7:57 AM, Art<grenander at gmail.com> wrote:
> I have the following problem:
> ipdb> p type(self)
> <class 'component.BiasComponent'>
> ipdb> isinstance(self, component.BiasComponent)
> I thought that isinstance(obj, type(obj)) == True.
> The specific problem is when I try to call the super of a class and it
> only occurs after 'reload'ing the file in the interpreter. What am I
> messing up by reloading? It doesn't occur if I using for the first
> time in a fresh interpreter session.
> ---> 32 class BiasComponent(ModelComponent):
> 33 def __init__(self, g, model):
> 34 super(BiasComponent, self).__init__(g, model)
> TypeError: super(type, obj): obj must be an instance or subtype of
> Seems like the self passed to __init__ is messed up in some way.
I would guess you're running into one of the caveats of using
reload(); see http://docs.python.org/library/functions.html#reload
Printing out id(BiasComponent) and id(type(obj)) both before and after
the reload() call should be instructive.
More information about the Python-list