by shigemk2

当面は技術的なことしか書かない

isinstance

class Hoge():
    def fuga(self):
        return 'fuga'


hoge = Hoge()
print hoge
print isinstance(hoge, Hoge)
print isinstance(hoge, Fuga)

<__main__.Hoge instance at 0x10beed560>
True
Traceback (most recent call last):
print isinstance(hoge, Fuga)
NameError: name 'Fuga' is not defined