[Tutor] isinstance -> instance

Bernard Lebel 3dbernard at gmail.com
Mon Feb 26 22:33:46 CET 2007


Hello,

Following the guidelines here, at the bottom of the page:
http://www.python.org/dev/peps/pep-0008/

I'm using isinstance() to test the type of some data.
Now the thing is that, what is the name to use for a class instance?

For example, say I run this:

class A:
    def __init__( self ):
        self.a = 'a'

a = A()

print type( a )

Outputs:
<type 'instance'>




Now if I test against the instance type like I would for integer,
strings and the likes:

isinstance( a, instance )

Outputs:
NameError: name 'instance' is not defined


So I'm a bit at a loss here. I don't want to know if the instance is
an instance of a specific class, I just want to know if it's an
instance.


Thanks
Bernard


More information about the Tutor mailing list