Raymond Hettinger <[email protected]> added the comment:
I've done some API experiments using a data munging example. See attached file.
The proposed API for takewhile() to save the last attribute is somewhat awkward
to use:
it = iter(report)
tw_it = takewhile(is_header, it)
for line in takewhile(is_header, tw_it):
print('Header:', repr(line))
if hasattr(tw_it, 'odd_element'):
it = chain([tw_it.odd_element], it)
print(mean(map(int, it)))
What is needed is a new itertool recipe to cover this use case:
headers, data = before_and_after(is_header, report)
for line in headers:
print('Header:', repr(line))
print(mean(map(int, data)))
----------
Added file: https://bugs.python.org/file50142/tmp_takewhile.py
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue44571>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com