Re: looking for a neat solution to a nested loop problem

2012-08-14 Thread 88888 Dihedral
Nobody於 2012年8月7日星期二UTC+8下午11時32分55秒寫道: > On Mon, 06 Aug 2012 21:02:33 -0700, Larry Hudson wrote: > > > > >> for i in range(N,N+100): > > >> for j in range(M,M+100): > > >> do_something(i % 100 ,j % 100) > > >> > > >> Emile > > > > > > How about... > > > >

Re: looking for a neat solution to a nested loop problem

2012-08-09 Thread 88888 Dihedral
Nobody於 2012年8月7日星期二UTC+8下午11時32分55秒寫道: > On Mon, 06 Aug 2012 21:02:33 -0700, Larry Hudson wrote: > > > > >> for i in range(N,N+100): > > >> for j in range(M,M+100): > > >> do_something(i % 100 ,j % 100) > > >> > > >> Emile > > > > > > How about... > > > >

Re: looking for a neat solution to a nested loop problem

2012-08-09 Thread 88888 Dihedral
Nobody於 2012年8月7日星期二UTC+8下午11時32分55秒寫道: > On Mon, 06 Aug 2012 21:02:33 -0700, Larry Hudson wrote: > > > > >> for i in range(N,N+100): > > >> for j in range(M,M+100): > > >> do_something(i % 100 ,j % 100) > > >> > > >> Emile > > > > > > How about... > > > >

Re: looking for a neat solution to a nested loop problem

2012-08-07 Thread 88888 Dihedral
Nobody於 2012年8月7日星期二UTC+8下午11時32分55秒寫道: > On Mon, 06 Aug 2012 21:02:33 -0700, Larry Hudson wrote: > > > > >> for i in range(N,N+100): > > >> for j in range(M,M+100): > > >> do_something(i % 100 ,j % 100) > > >> > > >> Emile > > > > > > How about... > > > >

Re: looking for a neat solution to a nested loop problem

2012-08-07 Thread Nobody
On Mon, 06 Aug 2012 21:02:33 -0700, Larry Hudson wrote: >> for i in range(N,N+100): >> for j in range(M,M+100): >> do_something(i % 100 ,j % 100) >> >> Emile > > How about... > > for i in range(100): > for j in range(100): > do_something((i + N) % 100,

Re: looking for a neat solution to a nested loop problem

2012-08-06 Thread Larry Hudson
On 08/06/2012 11:11 AM, Emile van Sebille wrote: for i in range(N,N+100): for j in range(M,M+100): do_something(i % 100 ,j % 100) Emile How about... for i in range(100): for j in range(100): do_something((i + N) % 100, (j + M) % 100) -=- La

Re: looking for a neat solution to a nested loop problem

2012-08-06 Thread Steven D'Aprano
On Mon, 06 Aug 2012 19:16:45 +0200, Tom P wrote: >> def my_generator(): >> yield 9 >> yield 100 >> for i in range(200, 250): >> yield i >> yield 5 >> >> > Thanks, I'll look at that but I think it just moves the clunkiness from > one place in the code to another. And i

Re: looking for a neat solution to a nested loop problem

2012-08-06 Thread Arnaud Delobelle
On 6 August 2012 16:52, Tom P 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 a

Re: looking for a neat solution to a nested loop problem

2012-08-06 Thread Emile van Sebille
On 8/6/2012 12:22 PM Grant Edwards said... On 2012-08-06, Tom P wrote: ah, that looks good - I guess it works in 2.x as well? I don't know. Let me test that for you... Yes, it works in 2.x as well. :) And from the docs, all the way back to 2.3! 9.7. itertools Functions creati

Re: looking for a neat solution to a nested loop problem

2012-08-06 Thread Grant Edwards
On 2012-08-06, Tom P wrote: no, I meant something else .. j runs through range(M, 100) and then range(0,M), and i runs through range(N,100) and then range(0,N) >>> >>> In 2.x: >>> >>> for i in range(M,100)+range(0,M): >>> for j in range(N,100)+range(0,N): >>>

Re: looking for a neat solution to a nested loop problem

2012-08-06 Thread Tom P
On 08/06/2012 08:29 PM, Grant Edwards wrote: On 2012-08-06, Grant Edwards wrote: On 2012-08-06, Tom P wrote: On 08/06/2012 06:18 PM, Nobody wrote: On Mon, 06 Aug 2012 17:52:31 +0200, Tom P wrote: consider a nested loop algorithm - for i in range(100): for j in range(100):

Re: looking for a neat solution to a nested loop problem

2012-08-06 Thread Grant Edwards
On 2012-08-06, Tom P wrote: > On 08/06/2012 06:18 PM, Nobody wrote: >> On Mon, 06 Aug 2012 17:52:31 +0200, Tom P 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 =

Re: looking for a neat solution to a nested loop problem

2012-08-06 Thread Grant Edwards
On 2012-08-06, Grant Edwards wrote: > On 2012-08-06, Tom P wrote: >> On 08/06/2012 06:18 PM, Nobody wrote: >>> On Mon, 06 Aug 2012 17:52:31 +0200, Tom P wrote: >>> consider a nested loop algorithm - for i in range(100): for j in range(100): do_something(i,

Re: looking for a neat solution to a nested loop problem

2012-08-06 Thread André Malo
* Tom P 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 value

Re: looking for a neat solution to a nested loop problem

2012-08-06 Thread Emile van Sebille
On 8/6/2012 10:14 AM Tom P said... On 08/06/2012 06:18 PM, Nobody wrote: On Mon, 06 Aug 2012 17:52:31 +0200, Tom P 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

Re: looking for a neat solution to a nested loop problem

2012-08-06 Thread Oscar Benjamin
On 6 August 2012 18:14, Tom P wrote: > On 08/06/2012 06:18 PM, Nobody wrote: > >> On Mon, 06 Aug 2012 17:52:31 +0200, Tom P 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 wan

Re: looking for a neat solution to a nested loop problem

2012-08-06 Thread Tom P
On 08/06/2012 06:03 PM, John Gordon wrote: In Tom P writes: 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 wan

Re: looking for a neat solution to a nested loop problem

2012-08-06 Thread Tom P
On 08/06/2012 06:18 PM, Nobody wrote: On Mon, 06 Aug 2012 17:52:31 +0200, Tom P 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

Re: looking for a neat solution to a nested loop problem

2012-08-06 Thread Nobody
On Mon, 06 Aug 2012 17:52:31 +0200, Tom P 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

Re: looking for a neat solution to a nested loop problem

2012-08-06 Thread Ian Foote
The function range can be called with more than one argument. For example: for i in range(N, N + 10): for j in range(M, M + 100): do_something(i, j) You can also call range with 3 arguments, if want a step size different to 1: for k in range(2, 11, 3): print(k) 2 5 8 Hope th

Re: looking for a neat solution to a nested loop problem

2012-08-06 Thread John Gordon
In Tom P writes: > 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 valu

Re: looking for a neat solution to a nested loop problem

2012-08-06 Thread Ethan Furman
Tom P 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 t

Re: looking for a neat solution to a nested loop problem

2012-08-06 Thread Oscar Benjamin
On 6 August 2012 16:52, Tom P 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

Re: looking for a neat solution to a nested loop problem

2012-08-06 Thread Oscar Benjamin
Are you familiar with the itertools module? itertools.product is designed for this purpose: http://docs.python.org/library/itertools#itertools.product Oscar. On 6 August 2012 16:52, Tom P wrote: > consider a nested loop algorithm - > > for i in range(100): > for j in range(100): >

looking for a neat solution to a nested loop problem

2012-08-06 Thread Tom P
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 py

Re: Loop problem while generating a new value with random.randint()

2010-02-15 Thread Paulo Repreza
Thanks for the help! Using while True helps alot! Paulo Repreza -- http://mail.python.org/mailman/listinfo/python-list

Re: Loop problem while generating a new value with random.randint()

2010-02-15 Thread Steve Holden
Paulo Repreza wrote: > Greetings, > > I'm having problems with a little script that I'm trying to finish, I > don't know if I'm in the right track but I know somebody is going to > help me. > > The script: > > # Import modules random for function randint > > import random > > # Generating a co

Re: Loop problem while generating a new value with random.randint()

2010-02-15 Thread Arnaud Delobelle
Jean-Michel Pichavant writes: > Paulo Repreza wrote: >> Greetings, >> >> I'm having problems with a little script that I'm trying to finish, >> I don't know if I'm in the right track but I know somebody is going >> to help me. >> >> The script: >> >> # Import modules random for function randint >

Re: Loop problem while generating a new value with random.randint()

2010-02-15 Thread Bruno Desthuilliers
Jean-Michel Pichavant a écrit : Paulo Repreza wrote: Greetings, I'm having problems with a little script that I'm trying to finish, I don't know if I'm in the right track but I know somebody is going to help me. (snip - problem already addressed by Jean-Michel...) while var != ranum:

Re: Loop problem while generating a new value with random.randint()

2010-02-15 Thread Jean-Michel Pichavant
Paulo Repreza wrote: Greetings, I'm having problems with a little script that I'm trying to finish, I don't know if I'm in the right track but I know somebody is going to help me. The script: # Import modules random for function randint import random # Generating a constant. var = 65 #

Loop problem while generating a new value with random.randint()

2010-02-15 Thread Paulo Repreza
Greetings, I'm having problems with a little script that I'm trying to finish, I don't know if I'm in the right track but I know somebody is going to help me. The script: # Import modules random for function randint import random # Generating a constant. var = 65 # Generating a random number

Re: newb loop problem

2008-08-14 Thread Dave
On Aug 13, 8:46 am, Sion Arrowsmith <[EMAIL PROTECTED]> wrote: > Dave <[EMAIL PROTECTED]> wrote: > >hitNum = 0 > >stopCnt = 6 + hitNum > >offSet = 5 > > >for i in range(0,10,1): > > The step argument to range defaults to 1: it's tidier to omit it. > Similarly, the start argument defaults to 0, so

Re: newb loop problem

2008-08-13 Thread Sion Arrowsmith
Dave <[EMAIL PROTECTED]> wrote: >hitNum = 0 >stopCnt = 6 + hitNum >offSet = 5 > >for i in range(0,10,1): The step argument to range defaults to 1: it's tidier to omit it. Similarly, the start argument defaults to 0, so you can drop that too. for i in range(10): > for x in range(hitNum,len

Re: newb loop problem

2008-08-13 Thread Larry Bates
Dave wrote: arrrggg, now I feel really dumb.. hitNum = 0 stopCnt = 6 + hitNum offSet = 5 for i in range(0,10,1): for x in range(hitNum,len(inLst), 1): print hitNum, stopCnt if x == stopCnt: break hitLst.append(inLst[x]) hitNum +=o

Re: newb loop problem

2008-08-13 Thread marek . rocki
Dave napisał(a): > Hey there, having a bit of problem iterating through lists before i go > on any further, here is > a snip of the script. > -- > d = "a1 b1 c1 d1 e1 a2 b2 c2 d2 e2 a3 b3 c3 d3 e3 a4 b4 c4 d4 e4 a5 b5 > c5 d5 e5" > inLst = d.split() > hitLst = [] > > hitNum = 0 > stopCnt = 6 + hitN

Re: newb loop problem

2008-08-13 Thread Dave
arrrggg, now I feel really dumb.. hitNum = 0 stopCnt = 6 + hitNum offSet = 5 for i in range(0,10,1): for x in range(hitNum,len(inLst), 1): print hitNum, stopCnt if x == stopCnt: break hitLst.append(inLst[x]) hitNum +=offSet

Re: newb loop problem

2008-08-12 Thread Dave
On Aug 13, 12:35 am, Larry Bates <[EMAIL PROTECTED]> wrote: > Dave wrote: > > Hey there, having a bit of problem iterating through lists before i go > > on any further, here is > > a snip of the script. > > -- > > d = "a1 b1 c1 d1 e1 a2 b2 c2 d2 e2 a3 b3 c3 d3 e3 a4 b4 c4 d4 e4 a5 b5 > > c5 d5 e5"

Re: newb loop problem

2008-08-12 Thread Larry Bates
Dave wrote: Hey there, having a bit of problem iterating through lists before i go on any further, here is a snip of the script. -- d = "a1 b1 c1 d1 e1 a2 b2 c2 d2 e2 a3 b3 c3 d3 e3 a4 b4 c4 d4 e4 a5 b5 c5 d5 e5" inLst = d.split() hitLst = [] hitNum = 0 stopCnt = 6 + hitNum for i in range(hitNu

newb loop problem

2008-08-12 Thread Dave
Hey there, having a bit of problem iterating through lists before i go on any further, here is a snip of the script. -- d = "a1 b1 c1 d1 e1 a2 b2 c2 d2 e2 a3 b3 c3 d3 e3 a4 b4 c4 d4 e4 a5 b5 c5 d5 e5" inLst = d.split() hitLst = [] hitNum = 0 stopCnt = 6 + hitNum for i in range(hitNum,len(inLst),

Re: loop problem

2005-07-13 Thread Paul Boots
Hi, First ;-) I don't know Tk or plot, but from looking at your code I see you want to plot a line a minute long, after that, all dots are drawn to the screen. You call >self.graph.addSet(x,y) My guess is that you have to explicitly draw to the screen using same call from graph

loop problem

2005-07-13 Thread Shankar Iyer ([EMAIL PROTECTED])
Hi, First, I want to thank those who responded to my question about "the plot module" yesterday.  I realize now that the question could have been vague.  There is a plot module, simply called "plot," that I am using, and I guess it is not a very widely circulated plotting utility.    Anyway, I