python - what does : do when assigning flags in a command line argument? -
i trying add command line arguments program writing. found tutorial on-line i'm not entirely sure of lines do.the main bit don't understand : when assigning flags eg. "hi:o:"
why there 2 :'s around o? not h or i? also, have understood correctly first list "hi:o:" shorthand , second list ["ifile=","ofile="]is more verbose version?
try: opts, args = getopt.getopt(argv,"hi:o:",["ifile=","ofile="]) except getopt.getopterror: print 'test.py -i <inputfile> -o <outputfile>' sys.exit(2) thanks!
the : indicates preceding option takes argument. is, call program -i inputfile -o outputfile.
your intuition second list correct.
Comments
Post a Comment