Ask Your Question

Revision history [back]

Not sure if it is a bug, but in your example n is a Python int, not a Sage integer. You can use srange(6) instead of range, it should work.

Not sure if it is a bug, but in your example n is a Python int, not a Sage integer. You can use srange(6) instead of rangerange(6), it in your first loop, then the ellipsis should work should work.

Not sure if it is a bug, but in your example n is a Python int, because it is created by the range function, not a Sage integer. You can use srange(6) instead of range(6) in your first loop, then the ellipsis should work should work.

Not sure if it is a bug, but in your example n is a Python int (not a Sage integer) because it is created by the range function, not a Sage integer. function,. You can use srange(6) instead of range(6) in your first loop, then the ellipsis should work.

Not sure if it is a bug, but in In your example n is a Python int (not a Sage integer) because it is created by the range function,. You can use srange(6) instead of range(6) in your first loop, then the ellipsis should work.

EDIT : since i am a player, i inspected further to decide whether it is a bug or a feature. In the documentation of ellipsis_iter it is claimed that the result is an iterator, and in the official Python documentation, iterators are required to provide a .next() method. With Python integers as "universe" (see below), ellipsis_iter provides an object that does not provide a .next() method:

sage: I = ellipsis_iter(int(-42),Ellipsis,int(42))
sage: I.next()
AttributeError: 'xrange' object has no attribute 'next'

Let us inspect why.

So, if you look at the source code of ellipsis_iter (see ellipsis_iter?? or the file src/sage/misc/misc.py), you will see that it uses xsrange. Now if you look at xsrange, you will see that it does something when the "universe" is ZZ, but just calls xrange Python builtin:

sage: xsrange(42)
<generator object generic_xsrange at 0x7f93417ea230>
sage: xsrange(int(42))
xrange(42)

Unfortunately, xrange is of type 'xrange' and is not an iterator (though it is an iterable since you can loop over it).

sage: xsrange(42).next()
0
sage: xrange(42).next()
AttributeError: 'xrange' object has no attribute 'next'

So, it is a bug, thanks for reporting.

In your example n is a Python int (not a Sage integer) because it is created by the range function,. You can use srange(6) instead of range(6) in your first loop, then the ellipsis should work.

EDIT : since i am a player, i inspected further to decide whether it is a bug or a feature. In the documentation of ellipsis_iter it is claimed that the result is an iterator, and in the official Python documentation, iterators are required to provide a .next() method. With Python integers as "universe" (see below), ellipsis_iter provides an object that does not provide a .next() method:

sage: I = ellipsis_iter(int(-42),Ellipsis,int(42))
sage: I.next()
AttributeError: 'xrange' object has no attribute 'next'

Let us inspect why.

So, if you look at the source code of ellipsis_iter (see ellipsis_iter?? or the file src/sage/misc/misc.py), you will see that it uses xsrange. Now if you look at xsrange, you will see that it does something when the "universe" is ZZ, but just calls xrange Python builtin:

sage: xsrange(42)
<generator object generic_xsrange at 0x7f93417ea230>
sage: xsrange(int(42))
xrange(42)

See in the source code:

if universe is not ZZ:
    return xrange(start, end, step)

Unfortunately, xrange is of type 'xrange' and is not an iterator (though it is an iterable since you can loop over it).

sage: xsrange(42).next()
0
sage: xrange(42).next()
AttributeError: 'xrange' object has no attribute 'next'

So, it is a bug, thanks for reporting.

In your example n is a Python int (not a Sage integer) because it is created by the range function,. You can use srange(6) instead of range(6) in your first loop, then the ellipsis should work.

EDIT : since i am a player, i inspected further to decide whether it is a bug or a feature. In the documentation of ellipsis_iter it is claimed that the result is an iterator, and in the official Python documentation, iterators are required to provide a .next() method. With Python integers as "universe" (see below), ellipsis_iter provides an object that does not provide a .next() method:

sage: I = ellipsis_iter(int(-42),Ellipsis,int(42))
sage: I.next()
AttributeError: 'xrange' object has no attribute 'next'

Let us inspect why.

So, if you look at the source code of ellipsis_iter (see ellipsis_iter?? or the file src/sage/misc/misc.py), you will see that it uses xsrange. Now if you look at xsrange, you will see that it does something when the "universe" is ZZ, but just calls xrange Python builtin:

sage: xsrange(42)
<generator object generic_xsrange at 0x7f93417ea230>
sage: xsrange(int(42))
xrange(42)

See in the source code:

if universe is not ZZ:
    return xrange(start, end, step)

Unfortunately, xrange is of type 'xrange' and is not an iterator (though it is an iterable since you can loop over it).

sage: xsrange(42).next()
0
sage: xrange(42).next()
AttributeError: 'xrange' object has no attribute 'next'

So, it is a bug, thanks for reporting.

reporting, this is now trac ticket 18538.

In your example n is a Python int (not a Sage integer) because it is created by the range function,. You can use srange(6) instead of range(6) in your first loop, then the ellipsis should work.

EDIT : since i am a player, i inspected further to decide whether it is a bug or a feature. In the documentation of ellipsis_iter it is claimed that the result is an iterator, and in the official Python documentation, iterators are required to provide a .next() method. With Python integers as "universe" (see below), ellipsis_iter provides an object that does not provide a .next() method:

sage: I = ellipsis_iter(int(-42),Ellipsis,int(42))
sage: I.next()
AttributeError: 'xrange' object has no attribute 'next'

Let us inspect why.

So, if you look at the source code of ellipsis_iter (see ellipsis_iter?? or the file src/sage/misc/misc.py), you will see that it uses xsrange. Now if you look at xsrange, you will see that it does something when the "universe" is ZZ, but just calls xrange Python builtin:

sage: xsrange(42)
<generator object generic_xsrange at 0x7f93417ea230>
sage: xsrange(int(42))
xrange(42)

See in the source code:

if universe is not ZZ:
    return xrange(start, end, step)

Unfortunately, xrange is of type 'xrange' and is not an iterator (though it is an iterable since you can loop over it).

sage: xsrange(42).next()
0
sage: xrange(42).next()
AttributeError: 'xrange' object has no attribute 'next'

So, it is a bug, thanks for reporting, this is now trac ticket 18538.

, and the fix is ready for review.