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
Post a Comment