To interactively test my python script, I would like to create a Namespace object, similar to what would be returned by argparse.parse_args().
The obvious way,
>>> import argparse
>>> parser = argparse.ArgumentParser()
>>> parser.parse_args()
Namespace()
>>> parser.parse_args("-a")
usage: [-h]
: error: unrecognized arguments: - a
Process Python exited abnormally with code 2
may result in Python repl exiting (as above) on a silly error.
So, what is the easiest way to create a Python namespace with a given set of attributes?
E.g., I can create a dict on the fly (dict([("a",1),("b","c")])) but I cannot use it as a Namespace:
AttributeError: 'dict' object has no attribute 'a'
PS. The new exit_on_error option looks like a promising alternative to creating a Namespace object, but it is severely broken, apparently by design.
 
     
     
     
     
     
    