Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.082 X-Spam-Evidence: '*H*': 0.85; '*S*': 0.01; 'syntax': 0.04; '23,': 0.16; 'dictionaries': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.18; 'not,': 0.20; 'error': 0.23; 'define': 0.26; 'code:': 0.26; 'header:In-Reply- To:1': 0.27; '???': 0.30; 'message-id:@mail.gmail.com': 0.30; 'run': 0.32; 'skip:s 30': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'so,': 0.37; 'implement': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'subject:" ': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'more': 0.64; 'obvious,': 0.91; 'subject:FOR': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=PcA5bS3gTD8kxbq2gfsExCVakjevoUh9RPrQ+2POJ3M=; b=gndOUmfBDWK1gwZzIES99LXF9zrlXeM021+YqFpch0QNaQMhsMLfMhkP3ZxXBBqr8F iq1HzGLg7GluVYHm7ypXDUlvjnkfYAOn9wChfxvBj34K5pE5IZ1S/P4JzXJAPax7UCt2 hK87L4dl/znkBartx+IgC05JpLYH26Z+2Y1GdKEU4GmBEhEGn3IGhaNFua2dVi6ZvasV aRsp55GUC9gA4DvnIdrO3nwpoizWwNayY0NmB7kGwatAr6Ch3JOlvdyOUre+917eDssE jVdlgaj+vJwsa8IEk0irNzA3P3wOjD4zx1qtEcNAoaS2XBPULPlJkxv+HjTc57+4aDHx 8pgw== MIME-Version: 1.0 X-Received: by 10.52.91.230 with SMTP id ch6mr1058299vdb.42.1366699595110; Mon, 22 Apr 2013 23:46:35 -0700 (PDT) In-Reply-To: References: Date: Tue, 23 Apr 2013 16:46:35 +1000 Subject: Re: Running simultaneuos "FOR" loops From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1366699597 news.xs4all.nl 2229 [2001:888:2000:d::a6]:40653 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:44150 On Tue, Apr 23, 2013 at 4:40 PM, inshu chauhan 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