r/Python • • Jan 05 '18

Really??

Post image
2.0k Upvotes

317 comments sorted by

View all comments

Show parent comments

0

u/[deleted] Jan 05 '18

[deleted]

2

u/ForgottenWatchtower Jan 05 '18

I actually agree with Guido on that one. Undue complexity for such a rare problem.

https://mail.python.org/pipermail/python-3000/2007-July/008663.html

0

u/icp1994 Jan 05 '18 edited Jan 05 '18
first_loop_done, second_loop_done = False, False
while (...) and (not first_loop_done):
    ...
    for (...):
        if second_loop_done:
            break
        ...
        for (...):
            if (...):
                first_loop_done, second_loop_done = True, True
                break
            ...

-1

u/zardeh Jan 05 '18

In general, I'd argue that break and continue are things that shouldn't ever appear in python code. I don't believe I've ever seen a situation that couldn't be more gracefully handled another way.

0

u/lunatickid Jan 05 '18

.....?????????

1

u/zardeh Jan 05 '18

Give an example where you feel break or continue is appropriate, I'll give a nicer refactor.

1

u/Raijinili Jan 06 '18

Avoiding continue is pretty obvious: reverse the if check.

Avoiding break could be done by factoring out the loop to a new function and using return instead.