`isinstance` is better:

refer to:

http://stackoverflow.com/questions/707674/how-to-compare-type-of-an-object-in-python
http://stackoverflow.com/questions/1549801/differences-between-isinstance-and-type-in-python