You can pass a dict of globals to execfile. hence temp.py: print 3/4 ipython shell: In [1]: from __future__ import division In [2]: execfile('temp.py', {'division':division}) 0.75 Beyond this, I probably don't understand what you are doing.....