for / while else doesn't make sense
BartC
bc at freeuk.com
Wed Jun 15 13:27:25 EDT 2016
On 15/06/2016 18:03, Rustom Mody wrote:
> OTOH Duff's device shows terrifyingly unstructured code with nary a goto/break
> in sight
I agree, and these mostly originate in C. It's full of crude features
that should have been pensioned off decades ago, but amazingly it is
still around and highly influential!
> So break also has its uses. Lets just not pretend its structured
It's a short-circuit operator that gets you to the end of the current
loop block.
There's one here too:
if a:
b
c
else:
d
It's called 'else' and is unconditional (when you finish executing the
'c' line, you then skip to the end of the next block).
This is another short-circuit operator:
if a and b(c):
d
e
(I assume Python has short-circuit evaluation; if not then plenty of
languages do). When a is False, the b(c) function call is skipped.)
If that's not enough, then 'return' in most languages will let you
return early from a routine, skipping the rest of the function.
--
Bartc
More information about the Python-list
mailing list