5

When I run this is python console:

>>> 'b' in 'b' is 'b'

I get this result

True

Similar, when I run this:

>>> 'b' in 'b' == 'b'

The answer is still True, which greatly made me confused.

The experiments I have done:

>>> 'b' in ('b' is 'b')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: argument of type 'bool' is not iterable
>>> ('b' in 'b') is 'b'
False

Can anyone explain how this happened and the priority of python interceptor do the job of in, ==, and is?

Harbor
  • 69
  • 4

0 Answers0