isA function?

Roy Smith roy at panix.com
Sat Jul 13 17:00:34 EDT 2002


Is there a standard isA() function in Python?  It should take two 
arguments, an instance and a class, and return true if the object is a 
member of the class or one of the class's ancestors.

I know I can roll this myself with __class__.__bases__, but it seems 
like a common enough thing that there would be a built-in way to do it.  
I looked at the inspect module, and was surprised to not find it there.

We're writing some unit tests, and one of the tests is "foo() returns 
something which isA (bar)".



More information about the Python-list mailing list