Creating Scripts

A file containing Python code is called a script. All you need to create scripts is a simple text editor, but it's best to use a Python-aware editor such as SciTE (see Figure 2-1) or IDLE (which comes with the standard distribution of Python).

Just save your script with a .py extension, so that your operating system knows that it contains Python. To run a script, you typically just double-click it, or if you prefer the command line, type python followed by a space and the name of your script. Most Python editors will have a shortcut key to run the script you have been editing.

â– Note Python allows both spaces and tabs for indentation, but it is better to use four spaces. Most Python editors will be set this way, but you may have to check it in the Options dialog of your editor.

(www.scintilla.org/SciTE.html)"/>
Figure 2-1. Editing Python code with SciTE (www.scintilla.org/SciTE.html)

Was this article helpful?

0 0

Post a comment