First time here? Check out the FAQ!

Ask Your Question
1

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

asked 6 years ago

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!

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 6 years ago

updated 6 years ago

You can start here: https://docs.python.org/3/library/sys... and https://www.tutorialspoint.com/python... Briefly: N = sys.argv[1] should work.

Preview: (hide)
link

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: 6 years ago

Seen: 545 times

Last updated: Dec 18 '18