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...
>
> >
>
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...
>
> >
>
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...
>
> >
>
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...
>
> >
>
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,
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
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
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
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
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):
>>>
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):
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 =
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,
* 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
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
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
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
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
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
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
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
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
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
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):
>
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
25 matches
Mail list logo