On Wed, 31 Oct 2012 at 08:47AM -0700, mmarco wrote: > My view: since this was revealed to my as a problem by a professor in > my university, who had problems runnning in class something like this: > > for i in range(10): > print cos(i).n() > > i think that the result should be, at least, something that has > the .n() procedure implemented. That is: Integer seems like a good > choice for me. Besides, 0 should be converted to Integer(0) by the > preparser, right?
A bare "0" is converted by the preparser -- but inside the loop, there's nothing to preparse: the range() function directly returns Python ints, and i gets such an int without any opportunity for the preparser to intervene. Note that in other situations, you can avoid the Python int problem by using something like [0..9] or srange(10) instead of range(10). Those return Sage integers and not Python ints. (But of course that doesn't help right now with our cos() function.) Dan -- --- Dan Drake ----- http://math.pugetsound.edu/~ddrake -------
signature.asc
Description: Digital signature