Re: Determine an object is a subclass of another

2007-01-09 Thread Felipe Almeida Lessa
On 9 Jan 2007 07:01:31 -0800, abcd <[EMAIL PROTECTED]> wrote: > anyways, is there a way to check without having an instance of the > class? In [1]: class A: ...: pass ...: In [2]: class B(A): ...: pass ...: In [3]: issubclass(B, A) Out[3]: True In [4]: isinstance(B(), B) Out

Re: Determine an object is a subclass of another

2007-01-09 Thread Bruno Desthuilliers
abcd a écrit : > yea i meant to have animal extend thing and dog extend animalmy > mistake. > > anyways, is there a way to check without having an instance of the > class? > > such as, > > isinstance(Dog, (Animal, Thing)) ?? > > issubclass(Dog, Animal) Note that such tests should only be

Re: Determine an object is a subclass of another

2007-01-09 Thread abcd
yea i meant to have animal extend thing and dog extend animalmy mistake. anyways, is there a way to check without having an instance of the class? such as, isinstance(Dog, (Animal, Thing)) ?? thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: Determine an object is a subclass of another

2007-01-09 Thread Matimus
First you need to subclass the classes so that Dog actually is a subclass of Animal which is a subclass of thing... class Thing: pass class Animal(Thing): pass class Dog(Animal): pass class Weapon(Thing): pass class Gun(Weapon): pass Then you can use 'isinstance' >>>d = Dog() >>>is

Re: Determine an object is a subclass of another

2007-01-09 Thread Neil Cerutti
On 2007-01-09, abcd <[EMAIL PROTECTED]> wrote: > How can tell if an object is a subclass of something else? > > Imagine... > > class Thing: > pass > > class Animal: > pass > > class Dog: > pass > > d = Dog() > > I want to find out that 'd' is a Dog, Animal and Thing. Such > as... > > d

Determine an object is a subclass of another

2007-01-09 Thread abcd
How can tell if an object is a subclass of something else? Imagine... class Thing: pass class Animal: pass class Dog: pass d = Dog() I want to find out that 'd' is a Dog, Animal and Thing. Such as... d is a Dog d is a Animal d is a Thing Thanks -- http://mail.python.org/mailm