1.1.1 How to run a Python script
Your best way to get started with Python on Mac OS X is through the PythonIDE integrated development environment, see section 1.3 and use the Help menu when the IDE is running.
If you want to run Python scripts from the Terminal window command line or from the Finder you first need an editor to create your script. Mac OS X comes with a number of standard Unix command line editors, vi and emacs among them. If you want a more Mac-like editor BBEdit or TextWrangler from Bare Bones Software (see http://www.barebones.com/products/bbedit/index.shtml) are good choices. Their freeware BBEdit Lite is officially discontinued but still available. AppleWorks or any other word processor that can save files in ASCII is also a possibility, but TextEdit is not: it saves in .rtf format only.
To run your script from the Terminal window you must make sure that /usr/local/bin is in your shell search path before /usr/bin, where the Apple-supplied Python lives (which is version 2.2, as of Mac OS X 10.2.4).
To run your script from the Finder you have two options:
- Drag it to PythonLauncher
- Select PythonLauncher as the default application to open your script (or any .py script) through the finder Info window and double-click it.
PythonLauncher has various preferences to control how your script is launched. Option-dragging allows you to change these for one invocation, or use its Preferences menu to change things globally.
See About this document... for information on suggesting changes.