Hi
I had a simple argparse working on ubuntu bash. However now I am trying to run
the script on windows and it cannot work because cmd doesn't handle the glob
like bash does.
So I am attempting to modify my script to accommodate.
As i am running python 3.5 i can use glob.glob for a list of files I believe.
Now I am specifying my arguments as 2 arguments path and extension
python script.py /mypath/XML *xml
This is my current error I have had many.
TypeError was unhandled by user code
Message: can only concatenate list (not "str") to list
'
import argparse
import glob
parser = argparse.ArgumentParser(description=None)
def GetArgs(parser):
"""Parser function using argparse"""
# parser.add_argument('directory', help='directory use',
# action='store', nargs='*')
parser.add_argument("path", nargs="+")
parser.add_argument('-e', '--extension', default='', help='File extension
to filter by.')
args = parser.parse_args()
files = set()
files |= set(glob.glob(args.path + '/*' + args.extension))
return files
fileList = GetArgs(parser)
for file in fileList:
print(file)
At this became unsure of where to troubleshoot further.
Sayth
--
https://mail.python.org/mailman/listinfo/python-list