[IPython-User] %run and global variables

Tom Bennett tom.bennett@mail.zyzhu....
Thu Nov 24 01:30:13 CST 2011

Hi Fernando,

On Thu, Nov 24, 2011 at 1:15 AM, Fernando Perez <fperez.net@gmail.com>wrote:

> 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

I see. That clarifies it.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20111124/7eae1be2/attachment.html 

More information about the IPython-User mailing list