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


Groups > comp.lang.python > #44160

Re: Running simultaneuos "FOR" loops

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <insideshoes@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.076
X-Spam-Evidence '*H*': 0.85; '*S*': 0.00; 'nested': 0.07; 'builtin': 0.09; 'runs': 0.10; 'cc:addr:python-list': 0.11; 'combinations': 0.16; 'dictionaries': 0.16; 'earlier.': 0.16; 'loops': 0.16; 'items.': 0.19; 'cc:addr:python.org': 0.22; '(or': 0.24; 'cc:2**0': 0.24; 'holds': 0.26; 'this:': 0.26; 'second': 0.26; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'respective': 0.29; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'gary': 0.31; 'please.': 0.31; 'lists': 0.32; 'run': 0.32; 'url:python': 0.33; 'problem': 0.35; 'skip:s 30': 0.35; 'something': 0.35; 'no,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'thanks': 0.36; 'possible': 0.36; 'url:org': 0.36; 'list': 0.37; 'subject:" ': 0.39; 'url:mail': 0.40; 'first': 0.61; 'zip': 0.64; 'dont': 0.67; 'yes': 0.68; 'wish': 0.70; 'clearer': 0.84; '\xa0\xa0\xa0\xa0\xa0': 0.84; 'items,': 0.91; 'subject:FOR': 0.91; '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0': 0.91
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:cc:content-type; bh=IsaKPWlAVZEk25k/POAj03gB7fcTbXQbdIUhiY2tJqY=; b=TxdO2G6ZnGKUl7KVGAc2Qp/N2i1d24rdxIstFmFwfzrPOew5mAiMYwBDFCLzcS5dq9 CXi+a2PlAcQao9r8udLqYtR/wlLpW9ycaDzT0qqYTEIqCm2Zb8DXsQDMIMVKzdiQi/wh MrHVM6NNa3bo2VfhxjPMj12mRNMIwBAMU6JvolnIIm2wUnkZGEE3zY4YytTO/s4LBpU/ E6p2o51Zc3bmgUFBci2BhNtaX2w0K+tQraaAkW9e0N6fpElUo81sgLqhxOlS3JAb5n6h VJFRruzwBVknqwOViH+TmqBCR1/cQwjEHhMqnmSYnsKqOBmk6w107y7QPkHVhEcw2v2U LFrg==
MIME-Version 1.0
X-Received by 10.50.33.11 with SMTP id n11mr14164736igi.40.1366701486341; Tue, 23 Apr 2013 00:18:06 -0700 (PDT)
In-Reply-To <51762FEC.4080603@islandtraining.com>
References <CAFqGZRGmNj1Hsedz0j8aHw+0UN+a+RDOFNUd1fU2v22T5VyhGg@mail.gmail.com> <51762FEC.4080603@islandtraining.com>
Date Tue, 23 Apr 2013 12:48:06 +0530
Subject Re: Running simultaneuos "FOR" loops
From inshu chauhan <insideshoes@gmail.com>
To Gary Herron <gary.herron@islandtraining.com>
Content-Type multipart/alternative; boundary=089e0153873e9b83a804db01fc8a
Cc "python-list@python.org" <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.960.1366701488.3114.python-list@python.org> (permalink)
Lines 115
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1366701488 news.xs4all.nl 2266 [2001:888:2000:d::a6]:41841
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:44160

Show key headers only | View raw


[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
>
>

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web