This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
tutorials:python_stuff [2016/02/26 11:52]
amora ↷ Page moved from python_stuff to tutorials:python_stuff
tutorials:python_stuff [2017/07/16 21:34] (current)
amora [Command line options]
Line 17: Line 17:
- import sys, os +  ​import sys, os 
- ​import optparse +  import optparse 
-  +   
- #​parsing args +  #parsing args 
- ​parser=optparse.OptionParser("​usage:​ %prog [options]"​) +  parser=optparse.OptionParser("​usage:​ %prog [options]"​) 
- ​parser.add_option("​-r",​ "​--robot",​ dest="​robot",​ default="​lwr",​ type="​string",​ help="​robot name"​) +  parser.add_option("​-r",​ "​--robot",​ dest="​robot",​ default="​lwr",​ type="​string",​ help="​robot name"​) 
- ​(options,​ args)=parser.parse_args(sys.argv[1:​])+  (options, args)=parser.parse_args(sys.argv[1:​])
 options.<​variable>​ will contain the data you need from the command line. options.<​variable>​ will contain the data you need from the command line.
  • tutorials/python_stuff.txt
  • Last modified: 2017/07/16 21:34
  • by amora