Arg. Silly question!

ullrich at math.okstate.edu ullrich at math.okstate.edu
Mon May 8 13:59:44 EDT 2000


In article <3913BBF0.5F255D1E at san.rr.com>,
  Courageous <jkraska1 at san.rr.com> wrote:
>
> Okay, in all the documentation, I can't find the way that
> one goes about determining an object's type/ancestry.
>
> I have two different types of things that I want to do:
>
> 1. Figure out if an object is inherited from a particular
>    class.
>
> 3. Figure out if an object is an instance of a particular
>    class.

    Actually it looks like there may be a bit missing from
the replies so far: isinstance tells you whether an instance
is an instance of a certain class or a descendant class,
but that doesn't do exactly what you ask in (3). If (3)
is really exactly what you want you can do it with __class__:

if theinstance.__class__ == theclass:

DU

> Arg. I'm getting a headache. :)
>
> (And I ordered my copy of Guido's Essential Python 2 days
>  ago, but don't have it yet).
>
> C/
>


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list