เมื่อมองเข้าไปใน Queue.py ใน Python 2.6 ฉันพบโครงสร้างนี้ซึ่งฉันพบว่าแปลกเล็กน้อย:
def full(self):
"""Return True if the queue is full, False otherwise
(not reliable!)."""
self.mutex.acquire()
n = 0 < self.maxsize == self._qsize()
self.mutex.release()
return n
ถ้าmaxsize
เป็น 0 คิวจะไม่เต็ม
คำถามของฉันคือมันทำงานอย่างไรสำหรับกรณีนี้? วิธี0 < 0 == 0
ถือว่าเป็นเท็จ?
>>> 0 < 0 == 0
False
>>> (0) < (0 == 0)
True
>>> (0 < 0) == 0
True
>>> 0 < (0 == 0)
True