Ask Your Question
1

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

asked 2018-12-18 23:35:35 +0100

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

N=10
sage_command1
sage_command2
sage_command3
print(result)

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
1

answered 2018-12-19 22:46:32 +0100

updated 2018-12-19 22:47:50 +0100

You can start here: https://docs.python.org/3/library/sys... and https://www.tutorialspoint.com/python... 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

Stats

Asked: 2018-12-18 23:35:35 +0100

Seen: 512 times

Last updated: Dec 18 '18