[IPython-user] access to __main__

Jean-Francois Moulin jfrancis18@gmail....
Wed Oct 7 07:32:57 CDT 2009


a maybe stupid namespace question....
I am trying to launch some configuration scripts (for an instrument we
control with python) at ipython's startup, to avoid the burden of typing
run foo.py at each startup (foo is actually a long list of foos and bars)

I used a specific ipythonrc-myenv configuration file which includes a
execfile ./nicos/refsansstartup_ipy.py statement.

ipython -pylab -profile myenv  crashes with the following

     67 import __main__
---> 69 Developing = __main__.Developing
     70 readonly   = __main__.readonly
     71 fake       = __main__.fake

AttributeError: 'FakeModule' object has no attribute 'Developing'
WARNING: Failure executing file: <./nicos/refsansstartup_ipy.py>

So it seems that I do not have access to the 'real' __main__ where these
   flags are created.

I have previously been playing with the ipython user space but I am a
bit puzzled here because if, in interactive mode I type
run ./nicos/refsansstartup_ipy.py everything runs fine... (which as far
as i remember was not the case last time I had to look in ipython's user
namespace). It is even more so puzzling for me when I think that I
should have used run -i to access the interactive variables.... (should
not I ?)

Side comment, if you have a strong opinion or tips about sharing global
flags across modules, please express yourself but please note that the
core of my question really is about ipython, not about using __main__ as
a mailbox!

Thanks for helping


More information about the IPython-user mailing list