相关疑难解决方法(0)

为什么表达式0 <0 == 0在Python中返回False?

在Python 2.6中查看Queue.py,我发现这个构造我发现有点奇怪:

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
Run Code Online (Sandbox Code Playgroud)

如果maxsize为0,则队列永远不会满.

我的问题是它如何适用于这种情况?如何0 < 0 == 0被认为是假的?

>>> 0 < 0 == 0
False
>>> (0) < (0 == 0)
True
>>> (0 < 0) == 0
True
>>> 0 < (0 == 0)
True
Run Code Online (Sandbox Code Playgroud)

python

133
推荐指数
5
解决办法
6748
查看次数

标签 统计

python ×1