How do I execute (not import) a python script from a python prompt?

bash, import, module, python

Solution

In Python 2, the builtin function `execfile` does this.

execfile(filename)

Problem

I need to execute a Python script from an already started Python session, as if it were launched from the command line. I'm thinking of similar to doing `source` in bash or sh.

Original source

Related problems