3

For example, How can I know whether there is an argument like args.manual_selection in args (args = parser.parse_args())

Parthesh Soni
  • 133
  • 1
  • 6

1 Answers1

3

One way to do it would be just to convert args to a dictionary

args = vars(parser.parse_args())

Then you can check for the existence of the key, e.g.

args.get("manual_selection", False)

If that returns False, the key does not exist. Of course the default returned for non-existence must not overlap with valid user input.

patrick
  • 4,455
  • 6
  • 44
  • 61