[Python-ideas] for/else syntax

Arnaud Delobelle arnodel at googlemail.com
Thu Oct 1 15:54:03 CEST 2009

2009/10/1 Antti Rasinen <ars at iki.fi>:
> I must say that calling for ... else "somewhat unintuitive" is the
> understatement of the year. The analogy with if ... else leads further
> astray than Odysseus.
> The feature itself is not bad. It's just that it is misnamed.
> I don't want the feature to be removed or even renamed (at least before
> Python 4). But the feature *is* badly named and unintuitive.

I agree.  I use it from time to time and I used to have to look up the docs
every time, because I couldn't remember wheteher the 'else:' clause
meant 'if did break' or 'if didn't break'.

I solved this problem by stopping thinking about it as while-else or
for-else, but rather as break-else.


More information about the Python-ideas mailing list