Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #44160 > unrolled thread

Re: Running simultaneuos "FOR" loops

Started byinshu chauhan <insideshoes@gmail.com>
First post2013-04-23 12:48 +0530
Last post2013-04-23 12:48 +0530
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Running simultaneuos "FOR" loops inshu chauhan <insideshoes@gmail.com> - 2013-04-23 12:48 +0530

#44160 — Re: Running simultaneuos "FOR" loops

Frominshu chauhan <insideshoes@gmail.com>
Date2013-04-23 12:48 +0530
SubjectRe: Running simultaneuos "FOR" loops
Message-ID<mailman.960.1366701488.3114.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

Thanks Gary.



>
> Be clearer about the problem please.
>
> Do you wish to produce a loop that:
>   On pass 1, each of p,k, and t hold the first item of their respective
> lists, and
>   on pass 2, each of p,k, and t hold the second item of their respective
> lists, and
>   so on
> until one (or all) lists run out?
>

Yes this is excatly what I want each loop holds the first item on each
pass.

>
> If that is what you want, then check out the zip builtin function.  But
> also consider this:  Do you care what happens if one list runs out before
> the others?
>

Yes, but all dictionaries have same number of items.

>
> Or is it something else you want?  Perhaps nested loops?
>   for  p in sorted(segments.iterkeys()):
>       for k in sorted(class_count.iterkeys()):
>           for j in sorted(pixel_count.iterkeys()):
>              # This will be run with all possible combinations of p,k, and
> t
>

No, I know about nested loops but I dont want that because all the loops
have same number of items, inner loops will run out earlier.


>
> Gary Herron
>
>
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web