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 taleinat
Recipients Yoni Lavi, rhettinger, steven.daprano, taleinat
Date 2019-12-19.07:49:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1576741758.69.0.300915142149.issue39094@roundup.psfhosted.org>
In-reply-to
Content
It seems to me that this would follow the same argument as in issue #18111: The real issue is that there's no good way to check if an arbitrary iterable is empty, unlike with sequences. Currently, callers need to wrap with try/except to handle empty iterators properly, or do non-trivial iterator "magic" to check whether the iterator is empty before passing it in.

I've tried think of other solutions, such as a generic wrapper for such functions or a helper to check whether an iterable is empty, and they all turn out to be very clunky to use and un-Pythonic.

Since we provide first-class support for iterators, and many builtins return iterators, giving the tools to handle the case where they are empty elegantly and simply seems prudent.
History
Date User Action Args
2019-12-19 07:49:18taleinatsetrecipients: + taleinat, rhettinger, steven.daprano, Yoni Lavi
2019-12-19 07:49:18taleinatsetmessageid: <1576741758.69.0.300915142149.issue39094@roundup.psfhosted.org>
2019-12-19 07:49:18taleinatlinkissue39094 messages
2019-12-19 07:49:18taleinatcreate