Is there any way that I pass arguments to my python script through command line while using ipython? Ideally I want to call my script as:

ipython -i --argument blah

and I want to be able to have --argument and blah listed in my sys.argv.

You can use one -- more option before that:

ipython -- --argument blah

Help of Ipython:

ipython [subcommand] [options] [-c cmd | -m mod | file] [--] [arg] ...

If invoked with no options, it executes the file and exits, passing the
remaining arguments to the script, just as if you had specified the same
command with python. You may need to specify `--` before args to be passed
to the script, to prevent IPython from attempting to parse them. If you
specify the option `-i` before the filename, it will enter an interactive
IPython session after running the script, rather than exiting.


$ cat 
import sys

$ ipython -- --argument blah
['', '--argument', 'blah']

$ ipython -- arg1 arg2
['', 'arg1', 'arg2']