Why in Python does “0, 0 == (0, 0)” equal “(0, False)”?

后端 未结 7 988
粉色の甜心
粉色の甜心 2020-12-04 09:20

In Python (I checked only with Python 3.6 but I believe it should hold for many of the previous versions as well):

(0, 0) == 0, 0   # results in a two elemen         


        
7条回答
  •  难免孤独
    2020-12-04 10:05

    In the first one Python is making a tuple of two things:

    1. The expression (0, 0) == 0, which evaluates to False
    2. The constant 0

    In the second one it's the other way around.

提交回复
热议问题