question about for cycle

tokland at gmail.com tokland at gmail.com
Sat Sep 29 23:17:36 CEST 2007


On 29 sep, 21:38, Zentrader <zentrad... at gmail.com> wrote:

> ctr_a=0
> ctr_b=0
> while ctr_a < len(generator_a):
>      this_el_a = generator_a[ctr_a]
>      while ctr_b <  len(generator_b):
>          this_el_b = generator_b[ctr_ b]
>          if something_happen:
>              ctr_b = len(generator_b)       ## break this loop
>          if something_else:
>              ctr_a = len(generator_a)       ## break outer while loop
>          ctr_b += 1
>      ctr_a += 1

Mmm, isn't a bit complicated?

Anyway, neither len() nor __getitem__ work on generators.




More information about the Python-list mailing list