Python: run script from interpreter
November 13, 2009 20:48:51 Last update: November 14, 2009 03:27:14
- Create a "Hello World" script:
if __name__ == "__main__": print "Hello World!"
- start the python interpreter and run the script with
execfile:>>> execfile('hello.py') Hello World! >>> print execfile.__doc__ execfile(filename[, globals[, locals]]) Read and execute a Python script from a file. The globals and locals are dictionaries, defaulting to the current globals and locals. If only globals is given, locals defaults to it. >>>
Easy email testing with http://www.ximailstop.com