2

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

4

You can separate ipython arguments from your script arguments using --:

ipython ipy_parse.py -- --proglogfile="wat"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.