Re: We should have an explicit concept of emptiness for collections

Bringing this back on list: On Tue, Aug 24, 2021 at 9:58 PM David Mertz, Ph.D. <david.mertz@gmail.com> wrote:
Sorry, I should have been more explicit. The several kinda of queues can all "contain" items, but do not respond to len().
yeah, I should have looked more closely at your list Though i would consider that an oversight, len(a_queue) could be handy. There is qsize() -- I wonder if there's a reason not to have __len__ do the same thing -- O(n) maybe? See Guido's point that there's an assumption tha len() will be O(1). This is an argument for the OP's point -- there is no standard way to check emptiness. -CHB -- Christopher Barker, PhD (Chris) Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython

What sort of code would be able to do anything useful with either a sequence or a queue? Queues aren’t iterable. This seems a case of hyper-generalization. On Tue, Aug 24, 2021 at 22:19 Christopher Barker <pythonchb@gmail.com> wrote:
-- --Guido (mobile)

On 8/24/21 10:26 PM, Guido van Rossum wrote:
On Tue, Aug 24, 2021 at 22:19 Christopher Barker wrote:
On Tue, Aug 24, 2021 at 9:58 PM David Mertz, Ph.D. wrote:
I don't think it's hyper-generalization of queues and sequences, but rather being consistent with the idea of something vs nothing. We can't iterate over integers, but not-zero numbers are still truthy. -- ~Ethan~

What sort of code would be able to do anything useful with either a sequence or a queue? Queues aren’t iterable. This seems a case of hyper-generalization. On Tue, Aug 24, 2021 at 22:19 Christopher Barker <pythonchb@gmail.com> wrote:
-- --Guido (mobile)

On 8/24/21 10:26 PM, Guido van Rossum wrote:
On Tue, Aug 24, 2021 at 22:19 Christopher Barker wrote:
On Tue, Aug 24, 2021 at 9:58 PM David Mertz, Ph.D. wrote:
I don't think it's hyper-generalization of queues and sequences, but rather being consistent with the idea of something vs nothing. We can't iterate over integers, but not-zero numbers are still truthy. -- ~Ethan~
participants (3)
-
Christopher Barker
-
Ethan Furman
-
Guido van Rossum