How to run script from interpreter?

Moshe Zadka moshez at zadka.site.co.il
Fri Jan 19 14:13:14 EST 2001


On Fri, 19 Jan 2001, "Dan Rolander" <dan.rolander at marriott.com> wrote:
> This doesn't work for me. I know how to import and how to use the if
> __name__ trick, but how can I execute a script from the interactive Python
> interpreter? That is, can I load a script and have it run from inside the
> interpreter? (I'm sure this is easy I'm just not seeing it.)

execfile(script_name)

E.g.,

execfile("test.py")
-- 
Moshe Zadka <sig at zadka.site.co.il>
This is a signature anti-virus. 
Please stop the spread of signature viruses!
Fingerprint: 4BD1 7705 EEC0 260A 7F21  4817 C7FC A636 46D0 1BD6




More information about the Python-list mailing list