[IPython-User] [IPython-user] using magic command inside the loop
Tue Dec 28 15:06:38 CST 2010
What version of IPython are you running? When I run this on 0.10 I get:
Traceback (most recent call last):
File "script.py", line 5, in <module>
AttributeError: 'NoneType' object has no attribute 'magic'
The reason is that an IPython interpreter has not been created.
Another option would be to name the scipy.pi to script.ipy and then
for i in range(5):
To run this do:
$ ipython scripy.py
On Tue, Dec 28, 2010 at 12:52 PM, unit <email@example.com> wrote:
> Hi all,
> So, I want to use %run inside a for loop in my script.py to call for another
> Something like this:
> #beginning of script.py
> import IPython
> ip = IPython.ipapi.get()
> for i in range(0,5):
> ip.magic('%run script_1.py')
> #end of the script.py
> However, when I execute script.py in my IPython shell, I get: "NameError:
> name 'ip' is not defined"
> My question is this: how come ip is not defined inside the for scope is I
> just defined it before entering the loop?
> Thank you very much for answering.
> View this message in context: http://old.nabble.com/using-magic-command-inside-the-loop-tp30547307p30547307.html
> Sent from the IPython - User mailing list archive at Nabble.com.
> IPython-User mailing list
Brian E. Granger, Ph.D.
Assistant Professor of Physics
Cal Poly State University, San Luis Obispo
More information about the IPython-User