1

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.

Ben
  • 51,770
  • 36
  • 127
  • 149
JS.
  • 14,781
  • 13
  • 63
  • 75
  • 1
    Have you tried actually accessing the names? It may simply be that they're hidden from `%whos`, even if they're really there. – Thomas K Nov 07 '13 at 19:05
  • @Thomas K: You're right! If you put this in an answer, I'll accept it. So is this a bug in IPython? – JS. Nov 07 '13 at 22:30

1 Answers1

2

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.

Thomas K
  • 39,200
  • 7
  • 84
  • 86