#18538: xsrange is not an iterator when called with Python ints or longs
-------------------------------------+-------------------------------------
       Reporter:  tmonteil           |        Owner:
           Type:  defect             |       Status:  new
       Priority:  major              |    Milestone:  sage-6.8
      Component:  misc               |   Resolution:
       Keywords:                     |    Merged in:
        Authors:                     |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/tmonteil/xsrange_is_not_an_iterator_when_called_with_python_ints_or_longs|  
4a59f332523192b4fd236f3c3e0533049eff9f37
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------
Description changed by tmonteil:

Old description:

> As reported in [http://ask.sagemath.org/question/26950/range-xrange-and-
> ellipsis-iteration/ this ask question]: `xsrange` claims to return an
> iterator while it does not provide a `.next()` method when called with
> Python ints or longs:
>

> {{{
> sage: xsrange(int(42)).next()
> AttributeError: 'xrange' object has no attribute 'next'
> }}}
>
> This is because in those cases, it returns an `xrange` object (which is
> only an iterable).

New description:

 As reported in [http://ask.sagemath.org/question/26950/range-xrange-and-
 ellipsis-iteration/ this ask question], there is a problem with
 `ellipsis_iter`:


 {{{
 sage: r = lambda n: (n-(n%2))//2
 sage: for n in range(6):
 ....:     print([r(n-k) + r(n+k) for k in (-n..n)])
 AttributeError: 'xrange' object has no attribute 'next'
 }}}

 This is due to the fact that, while `xsrange` claims to return an
 iterator, it does not provide a `.next()` method when called with Python
 ints or longs:

 {{{
 sage: xsrange(int(42)).next()
 AttributeError: 'xrange' object has no attribute 'next'
 }}}

 This is because in those cases, it returns an `xrange` object (which is
 only an iterable).

--

--
Ticket URL: <http://trac.sagemath.org/ticket/18538#comment:3>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to