I want to use sys.argv
to access the arguments passed to the script. Here is my code :
if __name__ == '__main__':
data = {}
if len(sys.argv) >= 2 :read_inputs(data, sys.argv[1])
else : print "ERROR : the config file is required in the command line"
if len(sys.argv) >= 3 :data['Parameters']['Mode'] = sys.argv[2]
print_data(data)
- I understand that
sys.argv[1]
andsys.argv[2]
refer to the arguments. - My arguments are contained in a text file.
What I cannot understand is how can I tell the code that it needs to read the arguments in that exact text file.
I used python Interface.py config.txt
but it didn't work.
Any ideas ?