On Tue, Sep 15, 2009 at 10:53 AM, Mariah Lenox <mariah.le...@gmail.com> wrote: > > Perhaps I do not understand sxrange / xsrange correctly. The > reference manual entries for them seem to be similar. Is > there a difference? (If one is just an alias for the other, > it would be best to say so. If they are different, the reference > manual needs to emphasize the difference.)
The file misc.py has this line: sxrange = xsrange Any chance you could post a patch with a statement that they are aliases added to the docs? > > Also the reference manual entry for > > sage.misc.misc.sxrange > > has the note > > : This function is called xsrange to distinguish it from the builtin > Python xrange command. > > Should it say "sxrange" rather than "xsrange"? > > Finally here is my attempt to use sxrange (xsrange > gives similar output): > > e = 1 > while true: > print Integer(10^e) > for i in sxrange(Integer(2),Integer(10^e)): > if i == 3: > break > e += 1 > > gives > > 10 > 100 > 1000 > 10000 > 100000 > 1000000 > 10000000 > 100000000 > 1000000000 > 10000000000 > 100000000000 > 1000000000000 > 10000000000000 > 100000000000000 > 1000000000000000 > 10000000000000000 > 100000000000000000 > 1000000000000000000 > 10000000000000000000 > Traceback (most recent call last): > File "zzzbug.py", line 7, in <module> > for i in sxrange(Integer(_sage_const_2 ),Integer(_sage_const_10 **e)): > File > "/home/mariah/sage/sage-4.1.1-x86_64-Linux-core2-fc/local/lib/python2.6/site-packages/sage/misc/misc.py", > line 1059, in generic_xsrange > for k in xrange(icount): > OverflowError: long int too large to convert to int > > I really want an iterator for the "for i in ..." loop. > > Is this a bug? Yes, I think that is a bug given the point of xrange, caused by an optimization. > Is there a better way to do what I want? Here is a way to do what you want: e = 1 while true: print Integer(10^e) i = Integer(2) while i < Integer(10^e): if i == 3: break print type(i) i += 1 e += 1 --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---