Is there a possibility to execute a Python script while being in interactive mode

lennykey picture lennykey · Jan 7, 2011 · Viewed 70.4k times · Source

Normally you can execute a Python script for example: python myscript.py, but if you are in the interactive mode, how is it possible to execute a Python script on the filesystem?

>>> exec(File) ???

It should be possible to execute the script more than one time.

Answer

fn. picture fn. · Jan 7, 2011

Use execfile('script.py') but it only work on python 2.x, if you are using 3.0 try this