I always thought operator is
determined if the given variable is of the given type. But I just determined it was not true:
>>> class A():
pass
...
>>> a = A()
>>> a is A
False
How do I test if a
is of type class A
?
Please advise.
Thanks, Boda Cydo.
You want isinstance(a, A)
.
Keep in mind, it might be better to avoid the isinstance
check by adding methods to A
that make it do what you want without explicitly determining that it is an A
.
is
determines if two objects are the same object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With