How do you make issubclass work

Nathan Bullock nathan_kent_bullock at yahoo.ca
Sat Sep 11 06:54:56 CEST 2004


Okay I have two files:

a.py:
-----
class cla_a(object): pass

class cla_c(object): pass

if __name__ == "__main__":
  mod = __import__("b")
  attr = getattr(mod, "cla_b")
  print issubclass(attr, cla_a)
  print issubclass(cla_c, cla_a)
-----

and b.py:
-----
from a import cla_a

class cla_b(cla_a): pass
-----

now if I do 'python a.py'
it gives me:
False
True

Why is cla_b a subclass and not cla_c?

I think that it has something to with the fact that cla_b is a
subclass of a different instance of cla_a or something like that. But
if that is the case how do I do this sort of thing in python?

Nathan Bullock

http://bullock.mooo.com



More information about the Python-list mailing list