Ubuntu comes with Python installed by default, as do many other versions of Linux and UNIXeven Mac OS X comes with Python preinstalled. Part of this is due to convenience because it is such a popular scripting language and it saves having to install it later if the user wants to run a script.
The Python binary is installed into /usr/bin/python; if you run that, you enter the Python interactive interpreter where you can type commands and have them executed immediately. Although PHP also has an interactive mode (use php a to activate it), it is neither as powerful nor as flexible as Python's.
As with Perl, PHP, and other scripting languages, you can also execute Python scripts by adding a shebang line (#!) to the start of your scripts that point to /usr/bin/python and then setting the file to be executable.
The third and final way to run Python scripts is through mod_python, which you can install through synaptic.
For the purposes of this introduction, we use the interactive Python interpreter because it provides immediate feedback on commands as you type them.
Was this article helpful?