On Mon, May 18, 2009 at 5:48 PM, Mike Witt <[email protected]> wrote:
>
> Is there a way to evaluate a string in the "same way" as sage would
> evaluate it?  Or, to put it another way, maybe I'm just confused about
> the way 'eval' works (or maybe eval isn't the right function) ...
> ...
> sage: frac=eval('1/2')
> sage: frac
> 0
> sage: type(frac)
> <type 'int'>

You can use sage_eval:

sage: sage_eval('1/2')
1/2
sage: type(_)
<type 'sage.rings.rational.Rational'>

This is basically equivalent for the following:

sage: eval(preparse('1/2'))
1/2

--Mike

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
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