I knew that Sage converted literal integers to sage Integers on
preparsing input, but had not realized until recently that the
following would not work:

sage: [q for q in range(100) if q.is_square()]
---------------------------------------------------------------------------
<type 'exceptions.AttributeError'>        Traceback (most recent call last)

/home/jec/<ipython console> in <module>()

<type 'exceptions.AttributeError'>: 'int' object has no attribute 'is_square'

--rather, one has to do this

sage: [q for q in range(100) if Integer(q).is_square()]
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]

or even this:
sage: [Integer(q) for q in range(100) if Integer(q).is_square()]
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]

if the elements of this list need further Integer methods to be called on them.

I did eventually find the srange() function, but find its name rather
un-guessable.  Why s?  Why not Irange, say?

-- 
John Cremona

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to