A quirk/gotcha of for i, x in enumerate(seq) when seq is empty

Arnaud Delobelle arnodel at gmail.com
Fri Feb 24 10:00:16 EST 2012


On 24 February 2012 14:54, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:

> for...else is a very useful construct, but the name is misleading. It
> took me a long time to stop thinking that the else clause executes when
> the for loop was empty.

This is why I think we should call this construct "for / break / else"
rather than "for / else".

-- 
Arnaud



More information about the Python-list mailing list