Advertisement
Guest User

Untitled

a guest
May 22nd, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. import getopt
  2. import sys
  3.  
  4. # simulate command line invocation
  5. sys.argv = ["myscript.py", "-l", "-d", "directory", "filename"]
  6.  
  7. # process options
  8. opts, args = getopt.getopt(sys.argv[1:], "ld:")
  9.  
  10. long = 0
  11. directory = None
  12.  
  13. for o, v in opts:
  14. if o == "-l":
  15. long = 1
  16. elif o == "-d":
  17. directory = v
  18.  
  19. print "long", "=", long
  20. print "directory", "=", directory
  21. print "arguments", "=", args
  22.  
  23. ## long = 1
  24. ## directory = directory
  25. ## arguments = ['filename']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement