Ask Your Question

Standalone Python/Sage Scripts

asked 2016-06-07 02:29:42 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

The tutorial example from

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?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2016-06-07 03:01:24 -0500

tmonteil gravatar image

I 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')"
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-06-07 02:29:42 -0500

Seen: 177 times

Last updated: Jun 07 '16