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


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

Re: Running simultaneuos "FOR" loops

Started byChris Angelico <rosuav@gmail.com>
First post2013-04-23 16:46 +1000
Last post2013-04-23 16:46 +1000
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 Chris Angelico <rosuav@gmail.com> - 2013-04-23 16:46 +1000

#44150 — Re: Running simultaneuos "FOR" loops

FromChris Angelico <rosuav@gmail.com>
Date2013-04-23 16:46 +1000
SubjectRe: Running simultaneuos "FOR" loops
Message-ID<mailman.955.1366699597.3114.python-list@python.org>
On Tue, Apr 23, 2013 at 4:40 PM, inshu chauhan <insideshoes@gmail.com> wrote:
> i have to implement the below line in one of my code:
>
> for  p in sorted(segments.iterkeys()) and for k in
> sorted(class_count.iterkeys()) and for j in sorted(pixel_count.iterkeys()):
>
> Its giving me a syntax error which is obvious, but how can I make all three
> for loop run simultaneously or any other way to do this simultaneous work
> ???

Define simultaneously. Do the three dictionaries have the same number
of keys? If so, look up zip() or itertools.izip; if not, you may have
to more clearly define "simultaneous".

ChrisA

[toc] | [standalone]


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


csiph-web