[Tutor] Re : Is instance of what?
spir
denis.spir at free.fr
Sat Jan 31 20:47:39 CET 2009
Le Sat, 31 Jan 2009 09:54:24 -0900,
Tim Johnson <tim at johnsons-web.com> a écrit :
> On Saturday 31 January 2009, Andre Engels wrote:
> <...>
> > > o=a
> <....>
> > Actually, it is false. To make it true, you have to do o=a() rather than
> > o=a
> You're correct. That was my typo.
> > > Is there a function that takes one
> > >
> > > argument and returns the class?
> > >
> > > Example:
> > >
> > > class = whatclass(o)
> <...>
> > o.__class__ (or rather o.__class__.__name__) will work.
> Understood. Thank you.
> tj
type(a) has been changed (since 2.2?) to return the same value as a.__class__
isinstance(a,t) will also be True for any supertype of a's type
class C():
pass
class D(C):
pass
o = D()
print isinstance(o,D), isinstance(o,C), isinstance(o,object)
==>
True True True
------
la vida e estranya
More information about the Tutor
mailing list