Skip to content
This repository

Ipython "source" command? #1001

Closed
antoine-levitt opened this Issue November 15, 2011 · 6 comments

3 participants

Antoine Levitt Thomas Kluyver Fernando Perez
Antoine Levitt

If I have a file named test.py with

print a

in it, and if I do this in ipython:

a = 1
%run "test.py"

it'll complain that it doesn't know a, because the environment is different. Any way Ipython could implement a bash-like "source" command that'll treat the script just as if it was entered in the interpreter? That kind of stuff is especially useful when using ipython as a matlab-like environment for scientific computing (do some computation, and then some plots of it or something)

Thomas Kluyver
Collaborator

It's already there: %run -i test.py.

There's a long paragraph in the docstring describing the normal behaviour before we explain the -i option, but I'm not sure if it can easily be improved.

Thomas Kluyver takluyver closed this November 15, 2011
Antoine Levitt
Thomas Kluyver
Collaborator
Antoine Levitt
Thomas Kluyver
Collaborator
Fernando Perez
Owner

Agreed, I think it's OK to leave it closed, the behavior is completely consistent: run?? is showing the correct sources, it's just that in this case the source is a wrapper around the original. But with run? showing the true docstring, it's working as desigined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.