This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients pavel-lexyr, rhettinger, serhiy.storchaka
Date 2021-07-09.16:42:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1625848964.7.0.402974088317.issue44571@roundup.psfhosted.org>
In-reply-to
Content
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)))
History
Date User Action Args
2021-07-09 16:42:44rhettingersetrecipients: + rhettinger, serhiy.storchaka, pavel-lexyr
2021-07-09 16:42:44rhettingersetmessageid: <1625848964.7.0.402974088317.issue44571@roundup.psfhosted.org>
2021-07-09 16:42:44rhettingerlinkissue44571 messages
2021-07-09 16:42:44rhettingercreate