1.3.1 Drag and drop

One of the easiest ways to launch a Python script is via ``Drag and Drop''. This is just like launching a text file in the Finder by ``dragging'' it over your word processor's icon and ``dropping'' it there. Make sure that you use an icon referring to the PythonInterpreter, not the IDE or Idle icons which have different behaviour which is described below.

Some things that might have gone wrong:

  • A window flashes after dropping the script onto the PythonInterpreter, but then disappears. Most likely this is a configuration issue; your PythonInterpreter is setup to exit immediately upon completion, but your script assumes that if it prints something that text will stick around for a while. To fix this, see section 1.7.3.

  • After dropping the script onto the PythonInterpreter, a window appeared which said: ``File contains \r characters (incorrect line endings?)''. That script probably originated on a Unix or Windows machine. You will need to change the line endings to the standard Mac usage. One way to do this is to open the file in BBedit ( which can easily change the line endings between Mac, DOS, and Unix styles.

  • When you waved the script icon over the PythonInterpreter, the PythonInterpreter icon did not hilight. Most likely the Creator code and document type is unset (or set incorrectly) - this often happens when a file originates on a non-Mac computer. See section 1.3.2 for more details.

See About this document... for information on suggesting changes.