Skip to content

Instantly share code, notes, and snippets.

@siwells
Created August 16, 2011 08:58
Show Gist options
  • Save siwells/1148690 to your computer and use it in GitHub Desktop.
Save siwells/1148690 to your computer and use it in GitHub Desktop.
Example of using optparse to work with command line arguments to build a *nix style CLI tool
import optparse
def main():
p = optparse.OptionParser()
p.add_option('--person', '-p', default="world")
options, arguments = p.parse_args()
print 'Hello %s' % options.person
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment