For expressions without parentheses, Python uses a concept called operator precedence to determine what to evaluate first.
The not
operator has a higher precedence than the and
operator, so your expression is parsed as:
(not self.is_alive())
and
self._queue.empty()
and self.is_alive()
is called first. If that returns True
, the not
expression produces False
, and the self._queue.empty()
expression is not even run. The False
result from not self.is_alive()
is returned. After all, there is no way the and
expression can become true with the left-hand-side of the expression already determined to be false.
If self.is_alive()
returns False
on the other hand, not False
becomes True
, and the result of self._queue.empty()
is returned from the whole expression.
So, provided self._queue.empty()
your function returns a boolean, the eof()
method will return False
if the object is still alive or the queue is not empty. It'll return True only if the object is no longer alive and the queue is empty.