Not scoping, typing.

When you do i+1, this is preparsed into

sage: preparse('[len(top_points(i+1)) for i in range(2,10)]')
'[len(top_points(i+Integer(1))) for i in range(Integer(2),Integer(10))]'

and the addition means that top_points is passed not a Python int, but a
Sage Integer, and your divisions aren't Python 2 truncating division.

To avoid this, you could use srange:

sage: [len(top_points(i)) for i in range(3,11)]
[5, 5, 5, 5, 5, 5, 5, 5]
sage: [len(top_points(i)) for i in srange(3,11)]
[30, 55, 91, 140, 204, 285, 385, 506]

or the `..` notation:

sage: [len(top_points(i)) for i in (3..10)]
[30, 55, 91, 140, 204, 285, 385, 506]

or anything which makes sure that you're not dividing an int by an int.


Doug

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

Reply via email to