Python: skipping if the last sys.argv is empty
I run the script: python script.py arg1 arg2, but I want to do the trick,
if the arg3 is provided then do something. Current code looking like this,
but doesn't work.
if len(sys.argv) == 3:
pannot = open(sys.argv[3],"w")
for v in anno2.values():
pannot.write("\t".join(v))
pannot.write("\n")
pannot.close()
else: print("if you want to get an annotation, please, provide third
argument")
The error is following: IndexError: list index out of range. Can you
please suggest what is the problem? (script was tested under windows).
No comments:
Post a Comment