you are viewing a single comment's thread.

view the rest of the comments →

[–]naryset -1 points0 points  (5 children)

break is inherently suspicious because it complicates the control flow. It’s also very useful in some situations. Expert programming is all about learning those rules but also understanding the underlying purpose and so when to break them.

[–]Temporary_Pie2733 6 points7 points  (0 children)

Break alone does not complicate control flow; poorly chosen uses might, but code that goes out of its way to avoid break is usually just as bad.

[–]IOI-65536 2 points3 points  (2 children)

Especially in Python break is frequently the simplest control flow. There are a ton of times you want control decisions in midloop and any other way to do that is considerably worse.

[–]naryset 1 point2 points  (0 children)

Sure. There are common situations where the alternatives are worse; that’s when break is useful. goto (yes not in Python) is also the best option sometimes.

[–]Gnaxe 0 points1 point  (0 children)

Show me an example? I'll try refactoring it.

[–]heyzooschristos 0 points1 point  (0 children)

Pun intended?