Idiom for consecutive loops?

Harald Kirsch kirschh at lionbioscience.com
Tue Aug 7 03:05:25 EDT 2001


bellman at lysator.liu.se (Thomas Bellman) writes:

> When looping over a list, how about this:
> 
>     lit = iter(haralds_list)
>     for item in lit:
> 	justDoIt(lit)
> 	if someTest(lit):
> 	    break
>     for item in lit:
> 	doSomethingElse(lit)
> 
> It doesn't work if you are using some stone-age version of
> Python, like the two and a half week old 2.1.1.  You've got
> to use something modern, like 2.2a1 (which seems to actually
> be a couple of days *older* than 2.1.1...).

Aah, that's what I was looking for. Too bad I cannot jump right on a
a1 release.

Thanks,
  Harald Kirsch
-- 
----------------+------------------------------------------------------
Harald Kirsch   | kirschh at lionbioscience.com | "How old is the epsilon?"
LION bioscience | +49 6221 4038 172          |        -- Paul Erdös
       *** Please do not send me copies of your posts. ***



More information about the Python-list mailing list