Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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