ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 14 Oct 2011 07:23:10 -0500How to import sage library to my python program?http://ask.sagemath.org/question/8380/how-to-import-sage-library-to-my-python-program/I write python program and must use SAGE to solve problem on my program,but i don't use command load "myprogram.py" on SAGE run program. How to run my program without this way? Thank you.Fri, 14 Oct 2011 07:10:38 -0500http://ask.sagemath.org/question/8380/how-to-import-sage-library-to-my-python-program/Answer by Jason Grout for <p>I write python program and must use SAGE to solve problem on my program,but i don't use command load "myprogram.py" on SAGE run program. How to run my program without this way? Thank you.</p>
http://ask.sagemath.org/question/8380/how-to-import-sage-library-to-my-python-program/?answer=12760#post-id-12760If you run the program with sage's python (i.e., sage -python myprogram.py), then you can do this:
from sage.all import *
at the top and then use Sage as normal in the program.
Only importing part of Sage is not supported, as many parts of Sage depend on other parts. So import the whole thing in one go.
I think you might be able to also do:
import sage.all
and then use Sage features by prepending things with sage.all.<whatever_sage_function>, like sage.all.factorial()
Fri, 14 Oct 2011 07:23:10 -0500http://ask.sagemath.org/question/8380/how-to-import-sage-library-to-my-python-program/?answer=12760#post-id-12760