[IPython-User] %run and global variables

Fernando Perez fperez.net@gmail....
Thu Nov 24 01:15:57 CST 2011


On Wed, Nov 23, 2011 at 10:26 PM, Tom Bennett
<tom.bennett@mail.zyzhu.net> wrote:
> Why is that?

Because %run by default executes your code in a completely empty
namespace, so it behaves as if it had been run at a system prompt in a
fresh python process.  After completion of the execution, the
interactive namespace gets updated with the variables from the script,
so that you can continue inspecting them and working with them
interactively.

In contrast, %run -i runs the script directly in the interactive
namespace, so that the variables in your namespace prior to execution
are directly available to the script.

Hope this clarifies things.

Cheers,

f


More information about the IPython-User mailing list