Python (programming language)

Python is an interpreted programming language. That means its programs are text files; to execute a Python program, you run a program called an interpreter that reads a text file full of Python code, and does what it says, and as long as an interpreter is available for one's platform of choice (UNIX-based or Unix-like operating systems typically come with one and the developers maintain ports to Windows and Mac OS X) the operating system and architecture are largely irrelevant since compilation isn't required. The name is a reference to Monty Python's Flying Circus.

Traditionally, interpreted programming languages are used as Scripting Languages, and not to develop whole applications. Partly, this is because the process of interpreting code is slower than the process of running code that's already been compiled into machine language. This is much less true than it once was, because after running a program once, Python stores it in "bytecode" that's been almost, but not quite, compiled into machine code. But for the most part, it's because interpreted programming languages have lacked access to the libraries that compiled programming languages had. Libraries like, say, Open GL, which allows C++ programmers to render fancy graphics without first telling the computer what a Sprite is, and how to move it around.

It is in this last area that Python breaks the mold. Like many interpreted languages before it, Python has extensions that are written in other languages, like C; but unlike those previous languages, Python extensions can be generated automatically from existing C code. If you're already familiar with the use of your favorite library in C, you can use it more-or-less as-is in Python; and with only a little extra work, you can use Python itself to tidy up the interface so that people who don't like C can use the library anyway.

Python therefore supports a bafflingly large array of functions (largely thanks to its expansive standard library), which Python programmers can tie together to make whole new programs without touching C (which the official interpreter, occasionally called CPython to distinguish it from unofficial interpreters that may be written in another language, is written in, but doesn't require knowledge of to simply use; decent knowledge of C would be required to work on the official interpreter but not the code it works with unless said code uses extensions written in C).

As for the language itself, Python is distinguished by its near-complete lack of braces. Where other programming languages require you to partition your blocks of code using punctuation, Python looks at how it's indented. Other languages are customarily indented to indicate how they're organized, but in Python, that's an actual rule of the language that you have to follow, or your program won't work. This frequently makes Python programs more readable than their equivalents in JavaScript and the like, and readability is one of the goals of the language, as mentioned on the Programming Language article on this very wiki.

The language takes pains to prevent the programmer from having to worry about memory management: it has an automatic garbage collector, meaning you don't have to worry about deleting variables after you're done with them; all variables are technically "pointers," but some types of variable can't be modified after they're created, which prevents issues that arise in C++ and the like where you don't know whether you're dealing with a variable or its Evil Twin; it handles type conversion automatically, meaning the difference between 2 and 2.0 is only as important as you want it to be; and the variable declarations that are used in most other languages to define what type of data a variable will hold are entirely absent from Python, where you "declare" a variable by assigning a value to it.

Note that currently the Python Software Foundation maintains two very different versions of Python; the 2.7.x branch is backward compatible with older code and would be better for old-school Python programmers who don't want to update their code, while the 3.x branch made several major changes to the language that are often incompatible with older code. If you're new to the language (or are new to programming in general and chose Python as a first language), looking into version 3 would be a good idea since code for it will likely be standard in the future. Fortunately, it isn't hard to find books that cover both; for example, the popular computer book publisher O'Reilly Media currently covers both branches in its books, Learning Python (which is intended for newcomers to the language) and Programming Python (which is aimed at more advanced Python programmers).

There are some popular codebases available for Python:
 * PyGame uses the SDL toolkit to provide easy 2D graphics management.
 * PyGlet is similar, but directly uses Open GL.
 * RenPy is for Visual Novel games.
 * Several 3D graphics engines:
 * PySoy
 * Panda3D
 * Python-Ogre
 * Blender3D
 * Evennia and GrailMUD are for Multi User Dungeons.

Python is used as a Scripting Language by:
 * Bridge Commander
 * Battlefield2
 * Civilization IV
 * EventScript 2.0, a plugin for Valve's Source Engine
 * Eve Online
 * Freedom Force
 * Frets On Fire
 * Jewel Quest 5
 * Lugaru
 * Severance: Blade of Darkness
 * The Temple Of Elemental Evil
 * Vampire: The Masquerade Bloodlines

And a rather good, freely available instructional book: Python for Software Design: How to Think like a Computer Scientist.