On 07/11/2020 09:16 PM, Rob Cliffe via Python-ideas wrote:

My gut feeling (backed by no evidence) is that dealing with the case of zero 
iterations is not needed frequently enough to cater for it.

My personal experience is that the case of no iterations is frequent enough, 
and a big enough pain to deal with, that if we're making changes we should 
include a way to deal with it.  Currently:

    if empty_iterable:
        # do whatever
    else:
        for it in iterable:
            # do something

or maybe:

    obj = object
    for obj in some_iterator:
        do_stuff()
    if obj is object:
        # iterator was empty
        do_different_stuff()

Either way,

    for obj in iterator:
        do_stuff
    elif empty:
        do_other_stuff()

would be much nicer.

--
~Ethan~
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/W4C6TNXU7XRUA4XKY2YEQKOENFVTUT25/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to