Pythonically-expressed nested-loop break?

John Roth johnroth at ameritech.net
Mon Jan 14 13:06:21 EST 2002


"Bengt Richter" <bokr at oz.net> wrote in message
news:a1u5v0$g0m$0 at 216.39.172.122...
> Snif. I thought I had an idea worth a comment ;-)
> Anyway, perhaps it was not adequately prefaced with
> explanation.
>
> The idea was/is to indicate how many loops a break is
> breaking by putting a single colon on the line immediately
> following the break. The colon is at the level of the
> beginning of the outermost loop being broken (and hence
> at same level as subsequent code that will be executed
> immediately after the break).

I used to think this was a good idea. Now that I'm
getting into the Test First Design part of XP, I'm becoming
a real believer in short and simple methods that can be
tested easily, and nested loops are one of the harder
to test constructs. If you break out the inner loop so it
can be tested in isolation, the 'break' statement becomes
completely irrelevant.

John Roth






More information about the Python-list mailing list