On 15/09/2025 17:04, Dima Pasechnik wrote:
On Mon, Sep 15, 2025 at 8:40 AM Ralf Hemmecke <[email protected]> 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)'
Another option is the command
sage --preparse file1.sage file2.sage [...]
that generates the preparsed files file1.sage.py, file2.sage.py, etc.
It calls src/bin/sage-preparse, and for other scenarios, you might want
to check
https://doc.sagemath.org/html/en/reference/repl/sage/repl/preparse.html
Regards,
TB
--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/sage-devel/8deda600-4515-4082-bf8b-91e193108f5d%40gmail.com.
--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/sage-devel/7392e268-e5b8-4aec-8f68-22f9319a9f65%40gmail.com.