Skip to content

Instantly share code, notes, and snippets.

@carlos-wong
Created April 28, 2013 16:48
Show Gist options
  • Save carlos-wong/5477470 to your computer and use it in GitHub Desktop.
Save carlos-wong/5477470 to your computer and use it in GitHub Desktop.
python: parse arguments
def _ParseArguments(args):
cmd = None
opt = _Options()
arg = []
for i in range(len(args)):
a = args[i]
if a == '-h' or a == '--help':
opt.help = True
elif not a.startswith('-'):
cmd = a
arg = args[i + 1:]
break
return cmd, opt, arg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment