Ask Your Question

How to create a "sage program" with command line input

asked 2018-12-18 16:35:35 -0500

Riccardo gravatar image

I am completely new to Sage and Pyhton, so this is probably a very trivial question, but I am not able to find any answer. I have a file script.sage


I use this script via sage script.sage and it does what I want. How can I modify this so that I can pass the variable N in the command line? Something like sage script.sage 10 and then it prints the result.

Thank you!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2018-12-19 15:46:32 -0500

updated 2018-12-19 15:47:50 -0500

You can start here: and Briefly: N = sys.argv[1] should work.

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


Asked: 2018-12-18 16:35:35 -0500

Seen: 100 times

Last updated: Dec 18 '18