I often run scripts with ipython -i or ipython --pdb. I would like to make a script which parses arguments without interfering with being run in this manner. I've attempted to do this below in the file ipy_parse.py:
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
'-lf', '--proglogfile',
help="File for logging",
dest="plogfile",
type=str
)
args = parser.parse_args()
print(args.plogfile)
However, when I run this with ipython ipy_parse.py --proglogfile="wat", I get the following output:
[TerminalIPythonApp] WARNING | Unrecognized alias: '--proglogfile=wat', it will probably have no effect.
None
Despite the fact that this script works normally when run with python ipy_parse.py --proglogfile="wat". How can I parse arguments without interfering with IPython arguments?
1 Answer 1
You can separate ipython arguments from your script arguments using --:
ipython ipy_parse.py -- --proglogfile="wat"
answered Mar 16, 2017 at 9:14
Nils Werner
37.3k7 gold badges85 silver badges108 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-py