On 15/09/2025 17:04, Dima Pasechnik wrote:
> On Mon, Sep 15, 2025 at 8:40 AM Ralf Hemmecke <
hemm...@gmail.com> wrote:
>>
>> On 9/15/25 15:26, Michael Orlitzky wrote:
>>> In general I would suggest using plain python files rather than a sage
>>> shell session for input. For example,
>>>
>>> #!/usr/bin/python3
>>> from sage.all import *
>>> print(ZZ(1) + ZZ(1))
>>>
>>> which can then be run with "sage -python" or (if you are using your
>>> distro's sage, or have installed it using meson/pip) just "python".
>>
>> Oh, that sounds like a good idea.
>>
>>> Using sage as a python library avoids the ipython history entirely,
>>> but the big downside is that you can't use any of the magic sage shell
>>> preparsing.
>>
>> Hmmmm, I think that I would like to have preparsing. Since I generate my
>> input files anyway ... is there perhaps a python script that does the
>> translation for me?
>
> there is a Python function for this:
>
> $ python
> Python 3.13.5 (main, Jul 15 2025, 09:22:39) [GCC 14.3.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from sage.all import preparse
>>>> preparse("2^5")
> 'Integer(2)**Integer(5)'