Hello,
I was thinking about giving loops names. And It would be interesting if through 
this name in a continue or break statement could be called.
A little example what I mean:


loop "outloop" while True:
    actmonth = datetime.datetime.now().month
    loop "innerloop" for i in range(0, int(input())):
        if datetime.datetime.now().month != actmonth:
            break "outloop"
        else:
            print("Waiting for a new Month...")



    # Do some stuff if loop ended before new Month

Without giving names it's always needed to define a new variable and a if 
statement outside of the innerloop, like this:


while True:
    actmonth = datetime.datetime.now().month
    shouldend = False
    for i in range(0, int(input())):
        if datetime.datetime.now().month != actmonth:
            shouldend = True
            break
        else:
            print("Waiting for a new Month...")

    if shouldend:
        break

    # Do some stuff if loop ended before new Month

It's possible without it, but it is more readable.
Maybe another option is, but that's too deep, to make loops to objects.

Best Regards,
Oskar Promeuschel
_______________________________________________
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/MWOQ67ARKHAUE6GN6WOVITPU3WAU5BEL/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to