Message358659
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. |
|
Date |
User |
Action |
Args |
2019-12-19 07:49:18 | taleinat | set | recipients:
+ taleinat, rhettinger, steven.daprano, Yoni Lavi |
2019-12-19 07:49:18 | taleinat | set | messageid: <1576741758.69.0.300915142149.issue39094@roundup.psfhosted.org> |
2019-12-19 07:49:18 | taleinat | link | issue39094 messages |
2019-12-19 07:49:18 | taleinat | create | |
|