Stop argparse from globbing filepath

前端 未结 3 1956
北恋
北恋 2021-01-12 23:08

I am using python argparse with the following argument definition:

parser.add_argument(\'path\', nargs=1, help=\'File path to process\')

Bu

3条回答
  •  迷失自我
    2021-01-12 23:43

    How do I get argparse not to glob the files?

    You don't.

    You get the shell to stop globbing.

    However. Let's think for a moment.

    You're saying this in your code

    parser.add_argument('path', nargs=1, help='File path to process')
    

    But you are actually providing wild-cards when you run it.

    One of those two is wrong. Either stop providing wild-cards at run time or fix argparse to allow multiple filenames.

提交回复
热议问题