Trouble porting glob bash behavior with argparse to windows shell

Peter Otten __peter__ at web.de
Tue May 3 17:15:45 EDT 2016


Sayth Renshaw wrote:

> Is there something obvious to this I am doing wrong?

>     parser.add_argument("path", nargs="+") 
 
The "+" implicitly turns args.path into a list

>     files |= set(glob.glob(args.path + '/*' + args.extension))

so the glob() argument is evaluated as

list + str + str

Try

name_pattern = "*" + args.extension
for path in args.path:
    files.update(glob.glob(os.path.join(path, name_pattern)))




More information about the Python-list mailing list