Skip to content

Instantly share code, notes, and snippets.

@nautilebleu
Created November 30, 2010 20:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nautilebleu/722377 to your computer and use it in GitHub Desktop.
Save nautilebleu/722377 to your computer and use it in GitHub Desktop.
How to capture patterns in glob style with Python 2.7 argparse
#!/usr/local/bin/python2.7
# coding=utf-8
import argparse
import pprint
from glob import glob
def main():
parser = argparse.ArgumentParser(description='Get some files according to a pattern')
parser.add_argument('pattern', type=file, action='store', nargs='+')
args = parser.parse_args()
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(args.pattern)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment