command line arguments - get python argparser attributes into script namespace -


i used in python scripts:

import sys my_int = int(sys.argv[1]) ...more commands... 

how can replicate exact functionality argparse module? need extract of variables parser? tedious.

i don't want answer this:

if __name__ == "__main__":     parser = argumentparser()     parser.add_argument("--my_int", type=int, dest="my_int")     args = parser.parse_args()     main(**vars(args)) 

because want able interrupt script in ipython , have variables still defined.

locals().update(vars(args)) 

is answer


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -