Profile

Click to view full profile
Hi, I'm Veerapat Sriarunrungrueang, an expert in technology field, especially full stack web development and performance testing.This is my coding diary. I usually develop and keep code snippets or some tricks, and update to this diary when I have time. Nowadays, I've been giving counsel to many well-known firms in Thailand.
view more...

Saturday, December 11, 2010

How to check subclass in python

An object oriented in python is different from full-support object oriented like java or etc. To check subclass, we need to use built-in function from python called "issubclass"

Ok, let's begin with issubclass(class, classinfo).
class A(object):
 pass

class B(A):
 pass

a = A()
b = B()

print issubclass(a.__class__,A)
print issubclass(b.__class__,B) 

It is easy right? ^^

No comments:

Post a Comment