Such as that:

    def starting_when(element):
        ...

    a_list[starting_when:]

Is equivalent to:

    from itertools import dropwhile

    def starting_when(element):
        ...

    list(dropwhile(lambda x: not starting_when(x), a_list))

And

    def ending_when(element:
        ...

    a_list[:ending_when]

To:

    from itertools import dropwhile

    def ending_when(element:
        ...

    list(itertools.takwhile(lambda x: not condition(x), a_list))
_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to