For example, How can I know whether there is an argument like args.manual_selection in args (args = parser.parse_args())
            Asked
            
        
        
            Active
            
        
            Viewed 195 times
        
    3
            
            
         
    
    
        Parthesh Soni
        
- 133
- 1
- 6
- 
                    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
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