Run python script from Finder rather than edit?

  1. Start up Automator
  2. Choose application
  3. In the Actions bar, select Library, and search for Shell
  4. Drag "Run Shell Script" to the right pane.
  5. Change pass input to "as arguments"
  6. Change the script to

    for f in "$@" do python "$f" done

  7. Save it (possibly in the application folder, but can be anywhere) as Python.app

Now if you want .py files to always launch with python:

  1. Select a .py file
  2. File -> Get Info
  3. In the Open with selection, choose Other, and select the Python.app you created.
  4. Click Change All

I suggest you install the latest version of Python (not the one installed on Mac OS X as of Mountain Lion). It includes PythonLauncher that does just what you want.

  1. Install the latest version of Python (download)
  2. Run "Update Shell Profile.command" (in Applications/Python 2.7) to make sure python is in your shell's PATH
  3. Select a .py file
  4. File -> Get Info
  5. In the Open with selection, choose Other, and select the PythonLauncher app (in Applications/Python 2.7)
  6. Click Change All