Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:

> For convenience, the takewhile iterator can also have
> additional attributes: a boolean attribute which indicates 
> that the falsifying element is set, and dynamic attribute 
> which is equal to orig_iterator 
> or chain([odd_element], orig_iterator).

Rather than graft a funky and atypical API onto takewhile(), it would be better 
to have a new tool that returns two iterators, the true steam, and a stream for 
the remaining values.  Either stream may be empty.  There is no need for a 
boolean flag attribute or a remaining stream attribute.  This design fits in 
better with the other itertools.

FWIW, we can already do this using groupby(), but it is only easy if we assume 
the first part of the stream is all true and the remainder of the stream is all 
false.  That isn't good enough for general application.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44571>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to