[issue44571] itertools: takedowhile()
Tim Peters
report at bugs.python.org
Mon Jul 12 12:30:50 EDT 2021
Tim Peters <tim at python.org> added the comment:
If you don't use the 'after` iterator, then of course you'll never see the values (if any) it would have yielded.
How could it possibly be otherwise? By design and construction, the `before` iterator ends before yielding the first (if any) transitional element.
As Raymond said at the start, the `takedowhile()` proposal appears much harder to use correctly, since there's no reasonably sane way to know that the last value it yields _is_ the transitional element (or, perhaps, that there was no transitional element, and the underlying iterable was just exhausted without finding one).
If the proposal were instead for `takewhile_plus_one_more_if_any()`, then at least the ugly name would warn about the surprising intended behavior ;-)
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44571>
_______________________________________
More information about the Python-bugs-list
mailing list