Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #26654
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <arnodel@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.003 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'example:': 0.03; 'algorithm': 0.03; 'nested': 0.07; 'suppose': 0.07; 'tom': 0.07; 'iterate': 0.09; 'cc:addr:python-list': 0.10; 'wrote:': 0.17; 'variable': 0.20; 'received:209.85.214.174': 0.21; 'subject:problem': 0.22; 'cheers,': 0.23; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In- Reply-To:1': 0.25; 'values': 0.26; 'wondering': 0.26; 'realize': 0.27; 'message-id:@mail.gmail.com': 0.27; 'this?': 0.28; 'initial': 0.28; "i'm": 0.29; 'received:google.com': 0.34; 'sequence': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'there': 0.35; 'but': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'things': 0.38; 'received:209.85.214': 0.39; 'header:Received:5': 0.40; '10,000': 0.65; 'august': 0.66; 'subject:looking': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=G6GmgQLr+YzK1iuUBCRB98nsX02HP82rqQPEh0qoOlI=; b=QOtNM/9kcxU7CIo4f+RmBNQZSf6RQZQx54p2B3a5FnqH/MGnimLXiu25UKMJdJsPV4 QMHlUdGkkudQ3ghQDNXgD05xR6nNf8d+e82gqPAojs9iuySG54GtyhHea1D1mOJEYoW5 52Y//UGBoEhksJZ4pQa8D4DyObHk2G/xCzY75hmtimnJrUka1W7EEPS5DWXJn8eOJuFz ECeECk5sPGmlU2A2apQcp7Lx/U5QEWHBSapHfReSx2/hvMsTs5q7kgjY6ophMXzUbxcy z2arw+TkST6xeOBkO6PK+nwmngMN8Cj+P54TREwN0fhlwBStxq5mblAPQrjo3v8yatcv yRWg== |
| MIME-Version | 1.0 |
| In-Reply-To | <a8a7hvF8crU1@mid.individual.net> |
| References | <a8a7hvF8crU1@mid.individual.net> |
| Date | Mon, 6 Aug 2012 21:14:25 +0100 |
| Subject | Re: looking for a neat solution to a nested loop problem |
| From | Arnaud Delobelle <arnodel@gmail.com> |
| To | Tom P <werotizy@freent.dd> |
| Content-Type | text/plain; charset=UTF-8 |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| 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.3028.1344284069.4697.python-list@python.org> (permalink) |
| Lines | 24 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1344284069 news.xs4all.nl 6908 [2001:888:2000:d::a6]:45264 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:26654 |
Show key headers only | View raw
On 6 August 2012 16:52, Tom P <werotizy@freent.dd> wrote:
> consider a nested loop algorithm -
>
> for i in range(100):
> for j in range(100):
> do_something(i,j)
>
> Now, suppose I don't want to use i = 0 and j = 0 as initial values, but some
> other values i = N and j = M, and I want to iterate through all 10,000
> values in sequence - is there a neat python-like way to this? I realize I
> can do things like use a variable for k in range(10000): and then derive
> values for i and j from k, but I'm wondering if there's something less
> clunky.
For example:
for i in range(100):
for j in range(100):
do_something((i + N)%100, (j + N)%100)
Cheers,
--
Arnaud
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
looking for a neat solution to a nested loop problem Tom P <werotizy@freent.dd> - 2012-08-06 17:52 +0200
Re: looking for a neat solution to a nested loop problem John Gordon <gordon@panix.com> - 2012-08-06 16:03 +0000
Re: looking for a neat solution to a nested loop problem Tom P <werotizy@freent.dd> - 2012-08-06 19:16 +0200
Re: looking for a neat solution to a nested loop problem Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-07 01:27 +0000
Re: looking for a neat solution to a nested loop problem Ian Foote <ian@feete.org> - 2012-08-06 17:07 +0100
Re: looking for a neat solution to a nested loop problem Ethan Furman <ethan@stoneleaf.us> - 2012-08-06 09:15 -0700
Re: looking for a neat solution to a nested loop problem Nobody <nobody@nowhere.com> - 2012-08-06 17:18 +0100
Re: looking for a neat solution to a nested loop problem Tom P <werotizy@freent.dd> - 2012-08-06 19:14 +0200
Re: looking for a neat solution to a nested loop problem Emile van Sebille <emile@fenx.com> - 2012-08-06 11:11 -0700
Re: looking for a neat solution to a nested loop problem Larry Hudson <orgnut@yahoo.com> - 2012-08-06 21:02 -0700
Re: looking for a neat solution to a nested loop problem Nobody <nobody@nowhere.com> - 2012-08-07 16:32 +0100
Re: looking for a neat solution to a nested loop problem 88888 Dihedral <dihedral88888@googlemail.com> - 2012-08-07 18:42 -0700
Re: looking for a neat solution to a nested loop problem 88888 Dihedral <dihedral88888@googlemail.com> - 2012-08-09 11:46 -0700
Re: looking for a neat solution to a nested loop problem 88888 Dihedral <dihedral88888@googlemail.com> - 2012-08-09 11:39 -0700
Re: looking for a neat solution to a nested loop problem 88888 Dihedral <dihedral88888@googlemail.com> - 2012-08-14 14:08 -0700
Re: looking for a neat solution to a nested loop problem Grant Edwards <invalid@invalid.invalid> - 2012-08-06 18:25 +0000
Re: looking for a neat solution to a nested loop problem Grant Edwards <invalid@invalid.invalid> - 2012-08-06 18:29 +0000
Re: looking for a neat solution to a nested loop problem Tom P <werotizy@freent.dd> - 2012-08-06 21:03 +0200
Re: looking for a neat solution to a nested loop problem Grant Edwards <invalid@invalid.invalid> - 2012-08-06 19:22 +0000
Re: looking for a neat solution to a nested loop problem Emile van Sebille <emile@fenx.com> - 2012-08-06 12:52 -0700
Re: looking for a neat solution to a nested loop problem André Malo <ndparker@gmail.com> - 2012-08-06 20:19 +0200
Re: looking for a neat solution to a nested loop problem Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-06 15:31 -0400
Re: looking for a neat solution to a nested loop problem Arnaud Delobelle <arnodel@gmail.com> - 2012-08-06 21:14 +0100
csiph-web