class C: ...
class C2 (C): ...
 
 
# What I want to do:
 
if x.__class__ in (C, C2):
   do_something_with (x)
 
# Requires an exhaustive genealogy, which normally is impractical and often impossible
 
 
# Another approach
 
class_tree = inspect.getclasstree ((x.__class__,))
if classtree_contains (class_tree, C):
   do_something_with (x)
 
# An awful lot of activity for a simple task
 
 
I'd expect a attribute name like __class__, but haven't found one in the doc and my doc-search time-out setting for simple things like this is about one hour.
 
Frederic
 
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to