That -v
option affects the behavior of the interpreter itself, not just the REPL. You get the extra import information regardless of whether you add the -i
option.
Here's the default script that launches ipython
(or at least one version of that)
1522:~/mypy$ cat /usr/local/bin/ipython3.5
#!/usr/local/bin/python3.5
# -*- coding: utf-8 -*-
import re
import sys
from IPython import start_ipython
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(start_ipython())
and from within an ipython session:
In [1153]: from IPython import start_ipython
In [1154]: start_ipython??
String form: <function start_ipython at 0xb697edac>
File: /usr/lib/python3/dist-packages/IPython/__init__.py
Definition: start_ipython(argv=None, **kwargs)
Source:
def start_ipython(argv=None, **kwargs):
"..."
from IPython.terminal.ipapp import launch_new_instance
return launch_new_instance(argv=argv, **kwargs)
Eventually the argv
are passed to an argparse
parser. Ipython populates that parser with arguments derived from its config files. So you have several options for setting parameters - default config, profile config, and commandline. But all of this is after the interpreter has been launched. Some things are acted on in the same was a with an interpreter REPL, but not all (-m
, but not -v
).
When -v
is used as zmo suggests, we see all the imports of ipython
code - which are quite a few. Are you interested in those, or are you more interested in imports related to your own script?
I use ipython
a lot to test answers, especially for numpy
. In fact my default ipython
call has the --pylab
flag. But to test stand alone scripts I use plain python
(often called from a terminal window in my editor). Sometimes though I'll %run
a script from within ipython
. That loads the module into the main workspace, making it easy to perform %timeit
tests on functions.
Other ipython
scripts use
#!/usr/bin/python
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point(...)
I don't write much code using this style, but I don't see how that kind initiation can pass argv
on through to the interpreter. By the time the module has been loaded and start running, the interpreter is already running.
In general it looks like ipython
handles options like -i
, -m
, -c
in basically the same way as the regular python
. It may doing so with its own code, rather than delegating to the interpreter. But things like -v
, -O
, -t
apply to the interpreter, not the REPL, and aren't handled by ipython
code.