Question

In Ipython 0.10, it was possible to run a script from the command-line, then from the interactive mode, immediately get access to the names in the namespace:

ipython -i some_script.py

%whos
    tom
    dick
    jane

I'm now using Python 3.3.2 and IPython 1.1.0. Somewhere along the line, this behavior changed. Now I get:

ipython3 -i some_script.py

%whos
    Interactive namespace empty

I now must start IPython, then %run the script to have the namespace preserved:

ipython3 -i
%run some_script.py
%whos
    tom
    dick
    jane

Is there a command-line option or technique that will give me the old behavior? I've tried

ipython3 -i -c "%run some_script.py"

but that doesn't work either.

I know, it's a lazy thing, but having one less step speeds up debugging spins.

Was it helpful?

Solution

Reposting as an answer: the names are actually placed into your interactive namespace, but names defined when IPython starts are hidden from %whos, so it says that the namespace is empty, even though it's not. If you try using the names, they should work normally.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top