How can I check if a type is a subtype of a type in Python? -


how can check if type subtype of type in python? not referring instances of type, comparing type instances themselves. example:

class a(object):     ...  class b(a):     ...  class c(object)     ...  # check instance subclass instance: isinstance(a(), a) --> true isinstance(b(), a) --> true isinstance(c(), a) --> false  # comparing types directly? some_function(a, a) --> true some_function(b, a) --> true some_function(c, a) --> false 

maybe issubclass?

>>> class a(object): pass >>> class b(a): pass >>> class c(object): pass >>> issubclass(a, a) true >>> issubclass(b, a) true >>> issubclass(c, a) false 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -