Alan Gauld wrote:
Dick Moores [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Encapsulate the while loop in a generator:
def count(limit):
n=0
while nlimit:
yield n
n += 1
All 3 are essentially the same, aren't they. Which makes me feel
even
dumber, because I
for x in xrange(2**31):
pass
Traceback (most recent call last):
File pyshell#16, line 1, in module
for x in xrange(2**31):
OverflowError: long int too large to convert to int
I can think of 2 workarounds for this 2**31 limitation in xrange().
Use a while loop instead. Or use 2
Dick Moores wrote:
for x in xrange(2**31):
pass
Traceback (most recent call last):
File pyshell#16, line 1, in module
for x in xrange(2**31):
OverflowError: long int too large to convert to int
I can think of 2 workarounds for this 2**31 limitation in xrange().
Use a
Dick Moores rdm at rcblue.com writes:
snip
I can think of 2 workarounds for this 2**31 limitation in xrange().
Use a while loop instead. Or use 2 or more for loops, keeping the
number of cycles in each under 2**31.
Are there others?
Write your own iterator:
def hugerange(minval,
for x in xrange(2**31):
pass
Traceback (most recent call last):
File pyshell#16, line 1, in module
for x in xrange(2**31):
OverflowError: long int too large to convert to int
Hi Dick,
Hmmm... I'd consider this a misfeature in the implementation. Apparently
xrange (and
for x in xrange(2**31):
pass
Traceback (most recent call last):
File pyshell#16, line 1, in module
for x in xrange(2**31):
OverflowError: long int too large to convert to int
Here are the suggestions I've received:
Danny's
#
def myxrange(m, n=None, skip=1):
Dick Moores wrote:
Here are the suggestions I've received:
snipped
All 3 are essentially the same, aren't they. Which makes me feel even
dumber, because I don't understand any of them. I've consulted 3
books, and still don't understand the use of yield.
Yes, they are pretty much the
--- Dick Moores [EMAIL PROTECTED] wrote:
Andrei's
Write your own iterator:
def hugerange(minval, maxval):
... val = minval
... while val maxval:
... yield val
... val += 1
All 3 are essentially the same, aren't they. Which
makes me feel even
dumber,
At 11:34 AM 10/10/2006, Kent Johnson wrote:
Dick Moores wrote:
Here are the suggestions I've received:
snipped
All 3 are essentially the same, aren't they.
Which makes me feel even dumber, because I
don't understand any of them. I've consulted 3
books, and still don't understand the use of
Dick Moores wrote:
At 11:34 AM 10/10/2006, Kent Johnson wrote:
Dick Moores wrote:
Here are the suggestions I've received:
snipped
All 3 are essentially the same, aren't they.
Which makes me feel even dumber, because I
don't understand any of them. I've consulted 3
books, and still
At 12:31 PM 10/10/2006, Marc Poulin wrote:
--- Dick Moores [EMAIL PROTECTED] wrote:
Andrei's
Write your own iterator:
def hugerange(minval, maxval):
... val = minval
... while val maxval:
... yield val
... val += 1
All 3 are essentially the same,
Dick Moores [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Encapsulate the while loop in a generator:
def count(limit):
n=0
while nlimit:
yield n
n += 1
All 3 are essentially the same, aren't they. Which makes me feel
even
dumber, because I don't understand any
12 matches
Mail list logo