[IPython-user] Using IPython magic commands in a script to be run in IPython

Brendan Arnold brendanarnold@gmail....
Mon Feb 15 09:14:29 CST 2010


Hi there,

I want to run a script which executes the IPython %run command to set
up an environment (like a lightweight import) before I work in
IPython. This will only ever be run itself from an IPython interpreter
using %run.

How do I do this?

I have tried

import IPython.ipapi
ip = IPython.ipapi.get()
ip.magic("run C:/filename")
ip.magic("run C:/filename2")

but somehow the IPython.ipapi is removed from scope after the first
execution of ip.magic ...

Brendan


More information about the IPython-user mailing list