This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients Jacob RR, ammar2, docs@python, serhiy.storchaka, steven.daprano
Date 2020-04-09.08:08:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
It was discussed in issue39816.

I do not think that calling len() and ignoring any exception is a good idea.

1. This may silence some exceptions (errors in the __len__ implementation, MemoryError, RecursionError, KeyboardInterrupt) which should not be silenced.

2. __len__() may have side effect.

3. __next__() may affects the result of __len__() (for example __next__() pops a value of the queue, and __len__() returns the size of the queue), so using the result of __len__() after calling __next__() may be misleading.

Since the original report was about 2.7 which is no longer maintained, I propose to close this issue as outdated.
Date User Action Args
2020-04-09 08:08:30serhiy.storchakasetrecipients: + serhiy.storchaka, steven.daprano, docs@python, ammar2, Jacob RR
2020-04-09 08:08:30serhiy.storchakasetmessageid: <>
2020-04-09 08:08:30serhiy.storchakalinkissue40202 messages
2020-04-09 08:08:30serhiy.storchakacreate