In ipython docs as well as run? command run? from the ipython prompt,
after execution, IPython interactive namespace is updated with all variables defined in the program (except __name__ and sys.argv)
In the section "Defined in the program" (slightly inaccurate use of terms), this does not mean "anywhere inside any nested functions found there" - it means "in the globals() the script / module you run ning. If you are in any nesting, globals()['myvar'] = [1,2,3] will still work just fine, just like your reliable export if it existed.
Change If you are in another module, you need to set the name in the global list of the source file - after import sys , if necessary, sys.modules["originalmodule"].myvar = [1, 2, 3] will do what you want.
source share