For example, How can I know whether there is an argument like args.manual_selection in args (args = parser.parse_args())
Asked
Active
Viewed 82 times
1
Parthesh Soni
- 83
- 5
-
1Try this. https://stackoverflow.com/questions/2521901/get-a-list-tuple-dict-of-the-arguments-passed-to-a-function – Dogukan Altay Aug 11 '20 at 14:33
-
1During debugging include a `print(args)` statement. – hpaulj Aug 11 '20 at 15:11
1 Answers
2
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
- 3,745
- 6
- 38
- 56