[IPython-dev] dictionaries and %run oddity
Wed Nov 30 07:25:20 CST 2011
On 30 November 2011 13:09, Kevin Buchs <firstname.lastname@example.org> wrote:
> My understanding is the iPython runs %run commands in a new instance of
> python, but then the namespace of that instance is inherited by the iPython
> level namespace. With that, it would seem to matter little that the
> definition of a() is separated from the invocation.
It's not a new instance of Python, but it is a new module, so it's a
separate namespace. When the script finishes, the variables from that
namespace are dumped in your interactive namespace, but that doesn't apply
to variables created in its module namespace later on (which is what you're
A simple workaround if you do want to see those variables is to use %run -i
x.py to run it directly in the main namespace.
> The unusual thing is that I found this behavior is not present if the
> global variable is an integer or list. So far, I have *only seen this
> with a dictionary.*
That is unusual. Can I ask you to double check this? I've tried with master
and with 0.11, and I see the same behaviour (b is not in my namespace) with
a dictionary, integer or list.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IPython-dev