[IPython-dev] execute() in IPython widgets
Matthias BUSSONNIER
bussonniermatthias at gmail.com
Wed May 15 11:32:14 EDT 2013
Le 15 mai 2013 à 17:26, Steve Jackson a écrit :
> Greetings,
>
> I have an application using the RichIPythonWidget with the QtInProcessKernelManager. I often need to execute python scripts as if their contents had been typed directly into the widget, i.e., in the __main__ namespace. The command "execfile('myfile.py')" works correctly for this. (The magic function "%run myfile.py" does not work, because the file does not execute in the __main__ namespace, but that's okay.)
Have a look at run -i
Why not load the file like %%load does, or set the content of input buffer (stripping 2 first line if there is encoding declaration and shebang) and then execute it ?
--
Matthias
More information about the IPython-dev
mailing list