On Thu, May 12, 2011 at 6:55 PM, Robert Kern <[email protected]> wrote:
> On Thu, May 12, 2011 at 19:40, Aaron Meurer <[email protected]> wrote:
>> On Thu, May 12, 2011 at 5:50 PM, Ronan Lamy <[email protected]> wrote:
>>> Le jeudi 12 mai 2011 à 16:41 -0600, Aaron Meurer a écrit :
>>>> Would it require the ast module?  That is only available on 2.6+.  But
>>>> that's better than nothing.  1/2 vs. S(1)/2 is by far the number one
>>>> gotcha that I see.
>>>
>>> That's really the only thing that prevents us from using a standard
>>> Python shell. I wish Python did the right thing and returned
>>> fractions.Fraction(1, 2) for 1/2... Since that's not the case, the next
>>> easiest option is to wrap all integer literals with Integer() - which
>>> shouldn't be hard in ipython, I hope.
>>>
>>
>> Oh, yeah, that would do it.  We should be able to do that with a
>> simple regex replacement, no advanced parsing like ast needed.
>>
>> We could also wrap float literals with Real(" "), so that you
>> automatically get lossless arbitrary precision floats.
>>
>> Actually, now that I think about it, it isn't so simple as regex,
>> because you don't want to do it with literals that are in strings.  So
>> probably the best way is to use an actual parser.
>
> You could use the tokenize module. I'm not sure if that's available on
> the App Engine, but it probably is.

It is, this:

import tokenize
tokenize.__file__

produces:

'/base/python_runtime/python_dist/lib/python2.5/tokenize.py'

Ondrej

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
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/sympy?hl=en.

Reply via email to