Given 2 callables checking when a condition arises and returning True:

    def starting_when(element):
        ...

    def ending_when(element:
        ...
Allow:

    a_list[starting_when:]

To be equivalent to:

    from itertools import dropwhile

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

And:

    a_list[:ending_when]

To:

    from itertools import takewhile

    list(takewhile(lambda x: not ending_when(x), a_list))
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to