That's fine, but that tells me that 'a' is an instance of 'A'.
It doesn't, however, tell me if 'a' is an instance or the actual class object.


Thanks
Bernard



On 2/26/07, Mike Hansen <[EMAIL PROTECTED]> wrote:
> Oops...I replied instead of replied all.
>
> > -----Original Message-----
> > From: Mike Hansen
> > Sent: Monday, February 26, 2007 2:43 PM
> > To: 'Bernard Lebel'
> > Subject: RE: [Tutor] isinstance -> instance
> >
> >
> >
> > > -----Original Message-----
> > > From: [EMAIL PROTECTED]
> > > [mailto:[EMAIL PROTECTED] On Behalf Of Bernard Lebel
> > > Sent: Monday, February 26, 2007 2:34 PM
> > > To: Tutor
> > > Subject: [Tutor] isinstance -> instance
> > >
> > > 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
> >
> > Shouldn't that be
> >
> > isinstance(a, A)
> >
> > ?
> >
> > Mike
> _______________________________________________
> Tutor maillist  -  [email protected]
> http://mail.python.org/mailman/listinfo/tutor
>
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to