What's the correct way to handle Unix style wildcard arguments using optparse in Python? I have:
myscript.py:
from optparse import OptionParser
parser = OptionParser()
parser.add_option("--input", dest="input", default=None, nargs=1)
parser.add_option("--outdir", dest="outdir", default=None, nargs=1)
(options, args) = parser.parse_args()
I want to be able to do:
myscript.py --input *.txt --outdir mydir/
I don't want to necessarily read the contents of all the files matching *.txt. I want myscript.py to access their filenames, because some scripts just pass on the filenames to other programs without needing to open/read the files. How can I get an iterator that returns the filenames, while still allowing other arguments like --outdir to be passed after the wildcard friendly option (in this case --input)? thanks.