Re: [Tutor] xrange() with start or stop > sys.maxint?

2011-05-19 Thread Alan Gauld
"Terry Carroll" wrote Is there any way to use xrange with a start or stop value that exceeds sys.maxint? Not in python v2(*), just use range(). In Python v3 xrange has been removed as has sys.maxint (*)Or at least up to 2.5, I don;t have 2.6 or 2.7... HTH, -- Alan Gauld Author of th

Re: [Tutor] xrange() with start or stop > sys.maxint?

2011-05-18 Thread spawgi
What is the version of python you are using? >From the documentation of python 2.71. http://docs.python.org/library/functions.html#xrange CPython implementation detail: xrange() is intended to be simple and fast. Implementations may impose restrictions to achieve this. The C implementation of Pyt

[Tutor] xrange() with start or stop > sys.maxint?

2011-05-18 Thread Terry Carroll
Is there any way to use xrange with a start or stop value that exceeds sys.maxint? import sys print sys.maxint 2147483647 start = sys.maxint-1 for i in xrange(start, start+1): ... pass ... start = sys.maxint for i in xrange(start, start+1): ... pass ... Traceback (most recent call last

Re: [Tutor] xrange

2008-03-18 Thread elis aeris
Oh i am good with range then, because it's not a real time program. On Tue, Mar 18, 2008 at 3:55 PM, Shrutarshi Basu <[EMAIL PROTECTED]> wrote: > I'm not entirely sure about this, but I think for range(), the entire > range of numbers is generated at one go, which could cause a > slow-down. But

Re: [Tutor] xrange

2008-03-18 Thread Alan Gauld
"Kent Johnson" <[EMAIL PROTECTED]> wrote >> Add a 3rd step-value argument to range. (You don't need the xrange >> on modern versions of Python BTW) > > Only if by 'modern' you mean Python 3; on Python 2.x there is a > difference between range() and xrange(). Though for a list of 20 > ints I > do

Re: [Tutor] xrange

2008-03-18 Thread Shrutarshi Basu
I'm not entirely sure about this, but I think for range(), the entire range of numbers is generated at one go, which could cause a slow-down. But xrange() generates the list of numbers one at a time. For a thousand, there shouldn't be much of a difference, but if you need a million or so go with xr

Re: [Tutor] xrange

2008-03-18 Thread elis aeris
ok i need about 500~1000 is that ok? my pet practice works works fine with it,but what should I watch out for? sorry for double reply kent, forgot to reply all. On Tue, Mar 18, 2008 at 3:21 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > Alan Gauld wrote: > > > Add a 3rd step-value argument to r

Re: [Tutor] xrange

2008-03-18 Thread Kent Johnson
Alan Gauld wrote: > Add a 3rd step-value argument to range. (You don't need the xrange > on modern versions of Python BTW) Only if by 'modern' you mean Python 3; on Python 2.x there is a difference between range() and xrange(). Though for a list of 20 ints I don't think it matters much. Kent _

Re: [Tutor] xrange

2008-03-18 Thread elis aeris
ok. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] xrange

2008-03-18 Thread Alan Gauld
"elis aeris" <[EMAIL PROTECTED]> wrote > for x in xrange (20, 0): >print x > > this doesn't work because it goes from a big number to a small > number, which > does nothing > but what if I need the for loop to go from a big number to a small > number? Add a 3rd step-value argument to range

[Tutor] xrange

2008-03-18 Thread elis aeris
x = 0 y = 0 for x in xrange (20, 0): print x this doesn't work because it goes from a big number to a small number, which does nothing but what if I need the for loop to go from a big number to a small number? ___ Tutor maillist - Tutor@python