[issue24866] Boolean representation of Q/queue objects does not fit behaviour of lists etc.

Frunit report at bugs.python.org
Fri Aug 14 12:06:01 CEST 2015


New submission from Frunit:

Usually, list-like objects return False when they are empty and True when at least one element is in the list. However, Queue (Python 2) resp. queue (Python 3) objects always return True. I am aware of that objects should always return True unless otherwise stated, but as queues are (at least in my perception) related to lists, they should behave similarly in this case.

Python3 (similar in Python2):
>>> import queue
>>> q = queue.Queue()
>>> bool(q)
True
(Should be False, in my opinion; the same for PriorityQueue and LifoQueue)

I searched for reasons for returning True in empty Queues, but I could not find any in the net or in the Python docs.

----------
messages: 248577
nosy: Frunit
priority: normal
severity: normal
status: open
title: Boolean representation of Q/queue objects does not fit behaviour of lists etc.
type: behavior
versions: Python 2.7, Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24866>
_______________________________________


More information about the Python-bugs-list mailing list