Message397202
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))) |
|
Date |
User |
Action |
Args |
2021-07-09 16:42:44 | rhettinger | set | recipients:
+ rhettinger, serhiy.storchaka, pavel-lexyr |
2021-07-09 16:42:44 | rhettinger | set | messageid: <1625848964.7.0.402974088317.issue44571@roundup.psfhosted.org> |
2021-07-09 16:42:44 | rhettinger | link | issue44571 messages |
2021-07-09 16:42:44 | rhettinger | create | |
|