Why does the expression 0 < 0 == 0 return False in Python?

前端 未结 9 1679
误落风尘
误落风尘 2020-11-22 01:48

Looking into Queue.py in Python 2.6, I found this construct that I found a bit strange:

def full(self):
    \"\"\"Return True if the queue is full, False oth         


        
9条回答
  •  旧时难觅i
    2020-11-22 02:22

    I'm thinking Python is doing it's weird between magic. Same as 1 < 2 < 3 means 2 is between 1 and 3.

    In this case, I think it's doing [middle 0] is greater than [left 0] and equal to [right 0]. Middle 0 is not greater than left 0, so it evaluates to false.

提交回复
热议问题