which is better: isinstance() or type()?

Benjamin Han bhan at andrew.cmu.edu
Thu Aug 1 19:30:34 CEST 2002


class Foo (list):
  pass

f=Foo()

print isinstance(f,Foo)
print type(f) is Foo


so which one is better? I understand that for arbitrary class that doesn't 
inherit from one of the pre-defined types will get <type 'instance'> after 
calling type().




More information about the Python-list mailing list