Disable/Remove argument in argparse

前端 未结 4 1037
攒了一身酷
攒了一身酷 2021-01-07 18:15

Is it possible to remove or disable an argument in argparse, such that it does not show in the help? How?

It is easy to add new arguments:



        
4条回答
  •  鱼传尺愫
    2021-01-07 18:55

    Is it possible to remove or disable an argument in argparse, such that it does not show in the help?

    Set help to argparse.SUPPRESS when you add the argument, like this:

    parser.add_argument('--arg1', help=argparse.SUPPRESS)
    

    This will prevent the argument from showing up in the default help output.

提交回复
热议问题