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.Tue, 07 Jun 2016 03:01:24 -0500Standalone Python/Sage Scriptshttp://ask.sagemath.org/question/33685/standalone-pythonsage-scripts/The tutorial example from
http://doc.sagemath.org/html/en/tutorial/programming.html#standalone-python-sage-scripts
is working only for integers. It does not work for symbolic expressions. It becomes working by renaming the script from "factor" to "factor.sage" and replacing the last line by
print factor(sage_eval(sys.argv[1],locals={'x':x}))
Is there anything wrong in my configuration of Sage?Tue, 07 Jun 2016 02:29:42 -0500http://ask.sagemath.org/question/33685/standalone-pythonsage-scripts/Answer by tmonteil for <p>The tutorial example from </p>
<p><a href="http://doc.sagemath.org/html/en/tutorial/programming.html#standalone-python-sage-scripts">http://doc.sagemath.org/html/en/tutor...</a></p>
<p>is working only for integers. It does not work for symbolic expressions. It becomes working by renaming the script from "factor" to "factor.sage" and replacing the last line by</p>
<p>print factor(sage_eval(sys.argv[1],locals={'x':x}))</p>
<p>Is there anything wrong in my configuration of Sage?</p>
http://ask.sagemath.org/question/33685/standalone-pythonsage-scripts/?answer=33686#post-id-33686I got the same, it seems indeed that the symbol `x` is not injected into the global namespace, but the following works:
./factor "sage.calculus.var.SR.symbol('x')^2+3*sage.calculus.var.SR.symbol('x')"
Tue, 07 Jun 2016 03:01:24 -0500http://ask.sagemath.org/question/33685/standalone-pythonsage-scripts/?answer=33686#post-id-33686