I have the following code and I want to use to extract the config parameter.
parser = argparse.ArgumentParser() parser.add_argument( "--config", type=str, default="src/config.yml", dest="config" ) My issue is that I cannot use parser.parse_args() (because I'm running the script from uvicorn and the parse_args is raising an error. Is there a way to retrieve the config parameter without the use of parse_args?
Other answers I've seen make use of parse_args.
parse_argsdoes the parsing of sys.argv and you can’t use it then presumably you’ll have to parse sys.argv yourself - have you tried to do that? Or perhaps you can adapt what is (I guess) a non-standard sys.argv to something that parse_args() can handle? To do that you’ll have to look at sys.argv.configparameter? Do you want the value that the parser would find in thesys.argv? Or do you want the correspondingActionobject? Or itsdefaultattribute?