Python: run script from interpreter 

Joined:
04/09/2007
Posts:
565

November 13, 2009 20:48:51    Last update: November 14, 2009 03:27:14
  1. Create a "Hello World" script:
    if __name__ == "__main__":
        print "Hello World!"
    

  2. 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.
    >>>
    

[ Comment  | Tags ]
 
Easy email testing with http://www.ximailstop.com