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().
not isinstance(...)
? – Augsburgnot
for every python construction? – Incudesnot in
works shows that you don't need to have thenot
before the expression but sometimes it can float around a bit, and it's possible that there could have been a preferred Pythonic way other thannot isinstance()
. For example, there could have been some subtle corner case which meant you should use a different form (rather liketype(obj) is list
works sometimes but is suboptimal.) – Commensuratex is not y
means the same asnot(x is y)
, andx not in y
means the same asnot(x in y)
. – Mimeograph