loading program's global variables in ipython

R. David Murray rdmurray at bitdance.com
Sun Mar 22 21:17:54 CET 2009


per <perfreem at gmail.com> wrote:
> hi all,
> 
> i have a file that declares some global variables, e.g.
> 
> myglobal1 = 'string'
> myglobal2 = 5
> 
> and then some functions. i run it using ipython as follows:
> 
> [1] %run myfile.py
> 
> i notice then that myglobal1 and myglobal2 are not imported into
> python's interactive namespace. i'd like them too -- how can i do
> this?
> 
>  (note my file does not contain a __name__ == '__main__' clause.)

I'm not familiar with IPython, but perhaps 'from myfile import *'
would do what you want?

--
R. David Murray           http://www.bitdance.com




More information about the Python-list mailing list