On May 7, 2:41 am, Amir <[EMAIL PROTECTED]> wrote: > Can I start a Sage session from C? I would need to pass commands, set > and get variables, and cleanly terminate the session. I would like to > do this as a mathlink module to call Sage from Mathematica.
As a fan of both Sage and Mathematica, I found this to be an interesting question. For example, the graph theoretic tools in Sage, via Networkx and N.I.C.E., are generally better than those currently in Mathematica. The graph visualization seems to be better in Mathematica at this point. So it's nice to use the tools together. I've got a sample notebook that does a couple things like this here: http://facstaff.unca.edu/mcmcclur/Mathematica/Sage/ It's pretty basic at the moment - mainly proof of concept, but it demonstrates a workable approach. The basic idea is to use Pythonika to access Sage via pexpect. I do have a question, as I'm fairly new to Python and Sage. I have several Python lines that look something like this: import pexpect child = pexpect.spawn('/Applications/sage/sage')" child.expect('.*') while child.after[-6:] != 'sage: ': child.expect('.*') The point behind the while statement is to continue reading until the next prompt is reached. I wonder how robust this is? Or whether there is a more standard approach? Mark --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@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-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---