Negative form of isinstance() in Python

mrl picture mrl · Jul 31, 2012 · Viewed 38.1k times · Source

How would I use a negative form of Python's isinstance()?

Normally negation would work something like

x != 1

if x not in y

if not a

I just haven't seen an example with isinstance(), so I'd like to know if there's a correct way to used negation with isinstance().

Answer

Silas Ray picture Silas Ray · Jul 31, 2012

Just use not. isinstance just returns a bool, which you can not like any other.