Well, at least for my use I "fixed" it with rstrip('.'), and it would possibly also work to convert to CDF and then to Integer, though that would possibly create other hard-to-find problems.
Well, it's worth raising the issue, even if the answer is negative. I for one never noticed int() didn't take a float string, even though it takes an int string or a float. Ronan Em Qui, 2008-11-27 às 14:55 -0600, Jason Grout escreveu: > mabshoff wrote: > > > > > > On Nov 27, 12:34 pm, "William Stein" <[EMAIL PROTECTED]> wrote: > >> On Thu, Nov 27, 2008 at 12:30 PM, mabshoff <[EMAIL PROTECTED]> wrote: > >> > >>> On Nov 27, 11:24 am, Jason Grout <[EMAIL PROTECTED]> wrote: > >>>> Ronan Paixão wrote: > >>>>> I just found a problem with Integer(). It doesn't seem to work fine with > >>>>> float strings. > >>>>> Those work fine: > >>>>> Integer("1") > >>>>> Integer(1.) > >>>>> But this doesn't: > >>>>> Integer("1.") > >>>> More data: > >>>> Integer(RR('1.')) works > >>>> Integer(RR('1.0')) works > >>>> Integer('1.0') doesn't work > >>>> I think that at least '1.' ought to be converted to an integer. > >>> Seems like a reasonable request. I would even allow ("$FOO.0"). Care > >>> to open a ticket? > >> I strongly disagree, since pure Python does not allow this, and > >> Sage's string conversion of integers should be consistent with that: > > > > Ok, that is certainly a killer argument against this. > > > > <SNIP> > > > > But how about some functions that do convert "1.0" and "1." to an > > Integer object? I have no good suggestion how to name there or where > > to stick them, but it seems that they could come in useful. One could > > always use regular expressions to transform the string since this is > > all about getting pexepct output from Scilab to play nice with Sage. > > > Since {RR,QQ}->Integer *does* work, you could do: > > Integer(sage_eval('1.')) > > Integer(sage_eval('2/2')) > > Integer(sage_eval('1.0')) > > or something like: > > try: > return Integer(RR(my_string)) > except TypeError: > return Integer(QQ(my_string)) > > > Of course, using sage_eval for this is a bit like using a sledgehammer > to hammer a nail. > > Jason > > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@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-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---