View the Most Wanted LQ Wiki articles.
LinuxQuestions.org > Linux Wiki > Python

From LQWiki

Jump to: navigation, search

Python is an object-oriented, interpreted language created by Guido van Rossum and named after the BBC's comedy "Monty Python's Flying Circus". Many people choose to liken it to Perl, Tcl or Java for whatever reason - most probably because it has the huge capabilities of Perl, the graphical ease of Tcl and a clean object-oriented syntax like Java. Although object-oriented in syntax, Python does not force you to use this idiom and thus you can program procedurally just as well. The language supports C/C++ extensions and even allows you to write such things in Java through Jython.

Syntax

One of the primary differences between Python and other descendents of the C language is the use of indentation whitespace to determine scope. This is best demonstrated with an example:

if spam == 1:
    # this code is considered inside
    # the scope of the if statement
# this code is considered outside
# the scope of the if statement

This means that no scope-closing syntactical construction is necessary; the fact that the indentation level is restored to that of the beginning statement means that the block has been closed. Consequently, it is important that the indentation in a program remain consistent throughout.

See also

External links

A great series of articles featuring Bruce Eckel (author of Thinking in C++ and Thinking in Java) focusing mainly on why he now prefers Python to Java or C++.


Share

Personal tools