I need to execute a Python script from an already running Python session, as if it were running from the command line. I am thinking about how to make source in bash or sh.
source
In Python 2, the built-in execfile function does this.
execfile
execfile(filename)
If you are using ipython (which I highly recommend for interactive python sessions), you can enter:
%run filename
or
%run filename.py
execute the module (and not import it). You will get file name completion, which is great for ReallyLongModuleName.py (not for you to name your modules like that or somehow).