1. Home
  2. Computing & Technology
  3. Python

Executing a Python Program: Shell or File?

From , former About.com Guide

4 of 4

Invoking the Python Interpreter: "Hello, Dmitri?" Does Not Work

An alternative means of execution is to call the Python interpreter manually, feeding the name of the file to be executed as an argument. So a program called 'myprogram.py' would be called as follows:

> python myprogram.py

Unfortunately, Windows users do not have the luxury of this choice automatically. By default, one must pass the name of the program as an argument to the Python interpreter.

On Windows 2000, the Python installer takes care of associating Python's '.py' suffix with the Python.File file type. For other versions of Windows, one must add '.py' to the PATHEXT environment variable. For more on troubleshooting Python program execution under Windows, see the Python Windows FAQ.

Even if you plan to use Python's live interpreter for a start, you should plan to acquaint yourself with the other way of writing Python programs. Go to the next section for information on choosing a programming editor.

Other tutorials in this series: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8

Explore Python
About.com Special Features

The Best Web Trends of the Decade

A look back at the best innovations, ideas and technologies over the last 10 years, More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Python

©2009 About.com, a part of The New York Times Company.

All rights reserved.