command line type argument when loading sage files

33 views
Skip to first unread message

Prakash Dey

unread,
Jun 20, 2014, 12:34:03 AM6/20/14
to sage-s...@googlegroups.com
Suppose I have a file ---------- 

test.sage
-------------------------
from sage.all import *
print sys.argv[1], sys.argv[2], sys.argv[3]


It could be run from bash terminal as-------------- $  test.sage 2 3 5
Here 2, 3, 5 are the three command line arguments and can be printed by:

             print sys.argv[1], sys.argv[2], sys.argv[3]

But it gives error when loaded in sage environment:------------------- 
                   sage: load "test.sage 2 3 5"
             or   sage: load "test.sage 2 3 5"
             or   sage: load "test.sage" 2 3 5
             or   sage: load("test.sage",2,3,5)

but the statement-------------  print sys.argv[0]               successfully prints the file name.
So I think it can be done.
It will be very helpful if someone posts a way out.

Reply all
Reply to author
Forward
0 new messages