All Topics  
Python (programming language)

 

 

 

 

 

Python (programming language)


 
 


Python is a general-purpose, high-level programming languageHigh-level programming language

A high-level programming language is a programming language that, in comparison to low-level programming languages, may be m...
. Its design philosophy emphasizes programmer productivity and code readability. Python's core syntax and semantics are minimalist, while the standard libraryStandard library

A standard library for a programming language is the library that is conventionally made available in every implementation o...
 is large and comprehensive.

Python supports multiple programming paradigmProgramming paradigm

A programming paradigm is a paradigmatic style of programming....
s (primarily
object orientedObject-oriented programming

In computer science, object-oriented programming is a computer programming paradigm....
, imperativeImperative programming

In computer science, imperative programming, as contrasted with declarative programming, is a programming paradigm that desc...
, and functionalFunctional programming

Functional programming is a programming paradigm that conceives computation as the evaluation of mathematical functions and ...
) and features a fully dynamic type system and automatic memory managementMemory management

Memory management is the act of managing computer memory....
; similar to PerlPerl

Perl, also Practical Extraction and Report Language is a dynamic procedural programming language designed by Larry Wa...
, RubyRuby (programming language) Summary

Ruby is a reflective, object-oriented programming language....
, Scheme, and TclTcl

Tcl is a scripting language created by John Ousterhout....
.

Python was first released by Guido van RossumGuido van Rossum

Guido van Rossum is a Dutch computer programmer who is best known as the author and Benevolent Dictator for Life of the Pyth...
 in 1991. The language has an open, community-based development model managed by the non-profit Python Software FoundationPython Software Foundation

The Python Software Foundation, is a non-profit organization devoted to the Python programming language....
. While various parts of the language have formal specifications and standards, the language as a whole is not formally specified. The de factoDe facto

De facto is a Latin expression that means "in fact" or "in practice"....
standard for the language is the CPythonCPython

CPython is the default, most-widely used implementation of the Python programming language....
 implementation.

History


Python was conceived in the late 1980s by Guido van Rossum at CWINational Research Institute for Mathematics and Computer Science

The National Research Institute for Mathematics and Computer Science is located in Amsterdam, The Netherlands and was founde...
 in the NetherlandsNetherlands

The Netherlands is the European part of the Kingdom of the Netherlands , which is formed by the Netherlands, the Neth...
 as a successor to the ABC programming languageABC programming language

ABC is an imperative general-purpose programming language and programming environment developed at CWI, Netherlands by Leo G...
 capable of exception handlingException handling

Exception handling is a programming language construct or computer hardware mechanism designed to handle the occurrence of s...
 and interfacing with the Amoeba operating systemAmoeba distributed operating system Summary

Amoeba was an experimental, microkernel-based distributed operating system developed by Andrew S....
. van Rossum is Python's principal author, and his continuing central role in deciding the direction of Python is reflected in the title given him by the Python community, Benevolent Dictator for Life (BDFL)Benevolent dictator

The benevolent dictator is a more modern version of the classical "enlightened despot", being an undemocratic or authoritari...
.

In 1991, van Rossum published the code (labeled version 0.9.0) to alt.sources. Already present at this stage in development were classes with inheritance, exception handling, functions, and the core datatypes of list, dict, str and so on. Also in this initial release was a module system borrowed from Modula-3Modula-3

Modula-3 is a now little-used programming language conceived as a successor to an upgraded version of Modula-2....
; van Rossum describes the module as "one of Python's major programming units". Python's exception model also resembles Modula-3's, with the addition of an else clause. In 1994 [news://comp.lang.python comp.lang.python], the primary discussion forum for Python, was formed, marking a milestone in the growth of Python's userbase.

Python reached version 1.0 in January 1994. The major new features included in this release were the functional programming tools lambdaLambda calculus Overview

In mathematical logic and computer science, lambda calculus, also ?-calculus, is a formal system designed to investiga...
, map, filter and reduceFold (higher-order function)

In functional programming, fold is a family of higher-order functions that process a data structure in some order and build ...
. van Rossum stated that "Python acquired lambda, reduce(), filter() and map(), courtesy of (I believe) a Lisp hacker who missed them and submitted working patches."

The last version released while van Rossum was at CWI was Python 1.2. In 1995, van Rossum continued his work on Python at the Corporation for National Research InitiativesCorporation for National Research Initiatives

The Corporation for National Research Initiatives is a not-for-profit organization founded in 1986 by Robert E....
 (CNRI) in RestonReston, Virginia

Reston is a planned community and an unincorporated census-designated place located in western Fairfax County, Virginia in t...
, VirginiaVirginia Overview

The Commonwealth of Virginia is one of the original thirteen colonies of the United States that revolted against British ru...
 from which he released several versions.

By version 1.4, Python had acquired several new features. Notable among these are the Modula-3Modula-3

Modula-3 is a now little-used programming language conceived as a successor to an upgraded version of Modula-2....
 inspired keyword arguments (which are also similar to Common LispCommon Lisp

Common Lisp, commonly abbreviated CL, is a dialect of the Lisp programming language, standardised by ANSI X3.226-1994....
's keyword arguments), and built-in support for complex numberComplex number

In mathematics, a complex number is a number of the form ...
s. Also included is a basic form of data hiding by name manglingName mangling Summary

In software compiler engineering, name mangling is a technique used to solve various problems caused by the need to resolve ...
, though this is easily bypassed.

During van Rossum's stay at CNRI, he launched the Computer Programming for Everybody (CP4E) initiative, intending to make programming more accessible to more people, with a basic 'literacy' in programming languages, similar to the basic English literacy and mathematics skills required by most employers. Python served a central role in this: because of its focus on clean syntax, it was already suitable, and CP4E's goals bore similarities to its predecessor, ABC. The project was funded by DARPA. As of 2007, the CP4E project is inactive, and while Python attempts to be easily learnable and not too arcane in its syntax and semantics, reaching out to non-programmers is not an active concern.

In 2000, the Python core development team moved to BeOpen.com to form the BeOpen PythonLabs team. CNRI requested that a version 1.6 be released, summarizing Python's development up to the point where the development team left CNRI. Consequently, the release schedules for 1.6 and 2.0 had a significant amount of overlap. Python 2.0 was the first and only release from BeOpen.com. After Python 2.0 was released by BeOpen.com, Guido van Rossum and the other PythonLabs developers joined Digital Creations.

The Python 1.6 release included a new CNRI license that was substantially longer than the CWI license that had been used for earlier releases. The new license included a clause stating that the license was governed by the laws of the State of Virginia. The Free Software FoundationFree Software Foundation

The Free Software Foundation is a non-profit corporation founded in October 1985 by Richard Stallman to support the free so...
 argued that the choice-of-law clause was incompatible with the GNU GPL. BeOpen, CNRI, and the FSF negotiated a change to Python's free software licenseFree software license

Free software is software which grants recipients the freedom to modify and redistribute the software....
 that would make it GPL-compatible. Python 1.6.1 is essentially the same as Python 1.6, with a few minor bug fixes, and with the new GPL-compatible license.

Python 2.0 borrowed a major feature from the functional programmingFunctional programming

Functional programming is a programming paradigm that conceives computation as the evaluation of mathematical functions and ...
 languages SETLSETL Summary

SETL is a very-high level programming language based on the mathematical theory of sets....
 and HaskellHaskell (programming language)

Haskell is a standardized pure functional programming language with non-strict semantics, named after the logician Haskell C...
: list comprehensionList comprehension

In programming languages, list comprehension is a construct for list processing, analogous to the set-builder notation, ...
s. Python's syntax for this construct is very similar to Haskell's, apart from Haskell's preference for punctuation characters and Python's preference for alphabetic keywords. Python 2.0 also introduced a garbage collectionGarbage collection (computer science)

In computer science, garbage collection is a form of automatic memory management....
 system capable of collecting reference cycles.

Python 2.1 was close to Python 1.6.1, as well as Python 2.0. Its license was renamed Python Software Foundation LicensePython Software Foundation License

The Python Software Foundation License is an open source license which is compatible with the GNU General Public License....
. All code, documentation and specifications added, from the time of Python 2.1's alpha release on, is owned by the Python Software FoundationPython Software Foundation

The Python Software Foundation, is a non-profit organization devoted to the Python programming language....
 (PSF), a non-profit organization formed in 2001, modeled after the Apache Software FoundationApache Software Foundation

The Apache Software Foundation is a non-profit corporation to support Apache software projects, including the Apache HTTP ...
. The release included a change to the language specification to support nested scopes, like other statically scoped languages. (The feature was turned off by default, and not required, until Python 2.2.)

A major innovation in Python 2.2 was the unification of Python's types (types written in C), and classes (types written in Python) into one hierarchy. This single unification made Python's object model purely and consistently object oriented. Also added were generatorGenerator (computer science)

In computer science, a generator is a special routine that can be used to control the iteration behaviour of a loop....
s which were inspired by Icon.

Python's standard library additions and syntactical choices were strongly influenced by JavaJava (programming language)

Java is an object-oriented programming language developed by James Gosling and colleagues at Sun Microsystems in the early 1...
 in some cases: the logging package, introduced in version 2.3, the SAXSax

Sax or sax' may refer to:* Saxophone...
 parser, introduced in 2.0, and the decoratorFacts About Python syntax and semantics

The syntax of the Python programming language is the set of rules that defines how a Python program will be written and inte...
 syntax that uses @, added in version 2.4

Future development


A Python Enhancement Proposal (or "PEP") is a standardized design document providing general information related to Python, including proposals, descriptions, and explanations for language features. PEPs are intended as the primary channel for proposing new features, and for documenting the underlying design rationale for all major elements of Python. Outstanding PEPs are reviewed and commented by the BDFL.

Python 3000


There are plans for a future version, to be called Python 3.0 (the project is called "Python 3000" or "Py3K") that will break backwards compatibility with the 2.x series in order to repair perceived flaws in the language. The guiding principle is to "reduce feature duplication by removing old ways of doing things".
Python 3.0a1, the first alpha release, was released on August 31, 2007, and a PEP (Python Enhancement Proposal) that details planned changes exists. The latest beta release, 3.0b2, was released on July 17, 2008.
Philosophy
Python 3.0 is being developed with the same philosophy as in prior versions, so any reference to Python philosophy will apply to Python 3.0 as well. However, as Python has accumulated new and redundant ways to program the same task, Python 3.0 has an emphasis on removing duplicative constructs and modules, in keeping with "There should be one—and preferably only one—obvious way to do it".

Nonetheless, Python 3.0 will remain a multi-paradigm languageMulti-paradigm programming language

A multiparadigm programming language is a programming language that supports more than one programming paradigm....
. Coders will still have options among object orientation, structured programmingStructured programming

Structured programming can be seen as a subset or subdiscipline of procedural programming, one of the major programming para...
, functional programmingFunctional programming

Functional programming is a programming paradigm that conceives computation as the evaluation of mathematical functions and ...
, and aspect-oriented programmingAspect-oriented programming

In software engineering, the programming paradigms of aspect-oriented programming, and aspect-oriented software developme...
 and other paradigms, but within such broad choices, the details are intended to be more obvious in Python 3.0 than they have become in Python 2.x.
Timeline and compatibility
Python 3.0a1, the first alpha release of Python 3.0, was released on August 31, 2007. A final release is, as of July 2008, planned for October 1, 2008. The Python 2.x and Python 3.x series will coexist for several releases in parallel, where the 2.x series exists largely for compatibility and with some new features being backported from the 3.x series. contains more information about the release schedule.

Like Perl 6Perl 6

, the creator of Perl, has called Perl 6 "the community's rewrite of Perl", because he has based the changes largely on 361 "reque...
, Python 3.0 will break backward compatibilityBackward compatibility

In technology, especially computing, a product is said to be backward compatible when it is able to take the place of an ol...
. There is no requirement that Python 2.x code will run unmodified on Python 3.0. There are basic changes such as changing the print statement into a print function (so any use of the print statement will cause the program to fail), and switching to Unicode for all text strings. Python's dynamic typing combined with the plans to change the semantics of certain methods of dictionaries, for example, makes perfect mechanical translationSource-to-source compiler

A "Source-to-source compiler" is a type of compiler that takes a high level language as its input and outputs a high level l...
 from Python 2.x to Python 3.0 very difficult. However, a tool called "2to3" does most of the job of translation, pointing out areas of uncertainty using comments or warnings. Even in an alpha stage, 2to3 appears to be fairly successful at performing the translation. recommends keeping one source (for the 2.x series), and producing releases for the Python 3.x platform using 2to3. The resulting code should not be edited until the program no longer needs to run on Python 2.x.

Python 2.6 will include forward compatibility features, as well as a "warnings" mode that will warn of potential transition problems. Warnings will be reported for builtins which will no longer exist in 3.0, as well as various old Python 2.x features that Python 3.0 will remove (see for more information).
Features
Some of the major changes scheduled for Python 3.0 are:

  • Changing print so that it is a built-in function, not a statement. This makes it easier to change a module to use a different print function, as well as making the syntax more regular. In Python 2.6 this can be enabled by entering from __future__ import print_function.
  • Moving reduce (but not map or filter) out of the built-in namespace and into functools (the rationale being that reduce is expressed more clearly as an accumulation loop);
  • Adding support for optional function annotations that can be used for informal type declarations or other purposes;
  • Unifying the str/unicode types, representing text, and introducing a separate immutable bytes type; and a mostly corresponding mutable buffer type, which both represent arrays of byteByte

    A byte is commonly used as a unit of storage measurement in computers, regardless of the type of data being stored....
    s;
  • Removing backward-compatibility features, including old-style classes, integer-truncating division, string exceptions, and implicit relative imports.

Usage


Some of the largest projects that use Python are the ZopeZope

Zope is an open-source, object-oriented web application server written in...
 application server, YouTubeYouTube Summary

YouTube is a popular free web site which lets users upload, view, and share video clips....
, and the original BitTorrent client. Large organizations that make use of Python include GoogleGoogle

Google Inc. is an American public corporation, first incorporated as a privately held corporation on 7 September 1998, that ...
, Yahoo!Yahoo!

Yahoo! Inc. is an American computer services company....
, CERNCERN

The Organisation Europenne pour la Recherche Nuclaire , commonly known as CERN, pronounced , is the world's largest p...
 and NASANASA

The National Aeronautics and Space Administration is an agency of the United States Government, responsible for the nation'...
. Air CanadaAir Canada

irline=Air Canada |logo=Air Canada Logo.svg|...
's reservation management system also uses Python for some of its components.

Python has also seen extensive use in the information securityInformation security

Information security, or sometimes Information Systems Security , deals with several different "trust" aspects of info...
 industry. Notably, in several of the tools offered by Immunity Security, in several of the tools offered by Core Security, in the Web application securityApplication security

Application Security encompasses measures taken to prevent exceptions in the security policy of an application or the underl...
 scanner Wapiti, and in the fuzzer TAOF. Python is commonly used in exploit development.

Python has been successfully embedded in a number of software products as a scripting language. It is commonly used in 3D animation packages, as in HoudiniHoudini (software)

Houdini is a high-end 3D animation package developed by Side Effects Software....
, Maya, Softimage XSIFacts About Softimage XSI

Softimage|XSI is a high-end three-dimensional graphics application developed by Softimage, Co., a subsidiary of Avid T...
, TrueSpaceTrueSpace

trueSpace is 3D computer graphics and animation software developed by Caligari Corporation. ...
, PoserPoser

Poser is a 3D rendering and animation software program optimized for models that depict the human figure in three-dimensiona...
, ModoModo (software) Overview

modo is an advanced polygon and subdivision surface modeling package developed by Luxology, LLC....
, NukeNuke (software) Summary

Nuke is the Academy Award-winning compositing software used by Digital Domain....
 and BlenderBlender (software) Overview

name = Blender| logo = | screenshot = | caption= Blender 2.42a...
. It is also used in GIMPGIMP

The GNU Image Manipulation Program or just GIMP is a free software raster image editor....
, InkscapeInkscape

Inkscape is a free software vector graphics editor....
, ScribusScribus

Scribus is a free, open source desktop publishing application....
 and Paint Shop Pro. ESRIESRI

ESRI was founded as Environmental Systems Research Institute in 1969 as a privately held consulting firm that speciali...
 is now promoting Python as the best choice for writing scripts in ArcGISArcGIS

ArcGIS ' is the name of a group of Geographic Information System software product lines produced by ESRI....
. It is also used in Civilization IVCivilization IV Overview

Sid Meier's Civilization IV is a turn-based strategy computer game released between October 25 and November 4, 2005 in N...
 as the control language for modding and event interaction. Eve OnlineEVE Online

EVE Online is a persistent world multiplayer online game set in space....
, a MMORPGMMORPG

A Massively-Multiplayer Online Role-Playing Game is an online computer role-playing game in which a large number of player...
, is also built using Python.

For many operating systems, Python is a standard component; it ships with most Linux distributions, with NetBSD, and OpenBSD, and with Mac OS X. SlackwareSlackware Overview

Slackware was one of the earliest Linux distributions, and is the oldest distribution still being maintained....
, Red Hat LinuxRed Hat Linux

Red Hat Linux is one of the most popular Linux distributions, assembled by Red Hat....
 and Fedora use the pythonic Anaconda installer. Gentoo LinuxGentoo Linux

Gentoo Linux is a Linux distribution named after the Gentoo Penguin....
 uses Python in its package management system, PortagePortage (software)

Portage is a package management system used by Gentoo Linux....
, and the standard tool to access it, emergePortage (software)

Portage is a package management system used by Gentoo Linux....
. PardusPardus (operating system)

Pardus is a GNU/Linux distribution which is developed in Turkey, as a product of the Pardus Project....
 uses it for administration and during system boot.

Syntax and semantics



Python was intended to be a highly readable language. It aims toward an uncluttered visual layout, frequently using English keywords where other languages use punctuation. Python requires less boilerplateBoilerplate (text)

Boilerplate refers to any text that is or can be reused in new contexts or applications without being changed much from the ...
 than traditional statically-typed structured languages such as C or Pascal, and has a smaller number of syntactic exceptions and special cases than either of these. Python uses indentation/whitespace, rather than curly bracesCurly bracket programming language Overview

Curly brace or bracket programming languages are those which use balanced brackets to make blocks in their syntax or f...
 or keywords, to delimit statement blockFacts About Statement block

In computer programming, a statement block is a section of code which is grouped together, much like a paragraph; such block...
s. An increase in indentation comes after certain statements; a decrease in indentation signifies the end of the current block. Python's statements include:

  • The if statement, which conditionally executes a block of code, along with else and elif (a contraction of else-if).
  • The for statementFor loop

    In most imperative computer programming languages, a for loop is a control flow statement which allows code to be executed i...
    , which iterates over an iterable object, capturing each element to a local variable for use by the attached block.
  • The class statement, which executes a block of code and attaches its local namespace to a classClass (computer science)

    In object-oriented programming, classes are used to group related variables and functions....
    , for use in object oriented programming.
  • The def statement, which defines a function.
  • The with statement which encloses a code block within a context manager (for example, acquiring a lockLock (computer science)

    In computer science, a lock is a synchronization mechanism for enforcing limits on access to a resource in an environment wh...
     before the block of code is run, and releasing the lock afterwards).


Each statement has its own semantics: for example, the def statement does not execute its block immediately, unlike most other statements.

CPython does not support continuationContinuation

In computing, a continuation is a representation of the execution state of a program at a certain point....
s, and according to Guido van Rossum it never will. However, better support for coroutineCoroutine

In computer science, coroutines are program components that generalize subroutines to allow multiple entry points and suspen...
-like functionality is provided in 2.5, by extending Python's generatorsGenerator (computer science)

In computer science, a generator is a special routine that can be used to control the iteration behaviour of a loop....
. Prior to 2.5, generators were lazyLazy evaluation

In computer programming, lazy evaluation is a technique that attempts to delay computation of expressions until the results ...
 iteratorIterator

In computer science, an iterator is an object which allows a programmer to traverse through all the elements of a collection...
s — information was passed unidirectionally out of the generator. As of Python 2.5, it is possible to pass information back into a generator function.

Methods on objects are functions attached to the object's class; the syntax instance.method(argument) is, for normal methods and functions, syntactic sugarFacts About Syntactic sugar

Syntactic sugar is a term coined by Peter J....
 for Class.method(instance, argument). Python methods have an explicit selfThis (computer science)

In many object-oriented programming languages, this is a keyword which can be used in instance methods to refer to the objec...
parameter to access instance data, in contrast to the implicit self in some other object-oriented programming languages (for example, JavaJava (programming language)

Java is an object-oriented programming language developed by James Gosling and colleagues at Sun Microsystems in the early 1...
, C++C++

C++ is a general-purpose, high-level programming language with low-level facilities....
 or RubyRuby (programming language)

Ruby is a reflective, object-oriented programming language....
).

Python uses duck typingDuck typing

In computer science, duck typing is a term for dynamic typing typical of some programming languages, such as Smalltalk, Visu...
 and has typed objects but untyped variable names. Type constraints are not checked at compile timeCompile time

In computer science, compile time, as opposed to runtime, is the time when a compiler compiles code written in a programming...
; rather, operations on an object may fail, signifying that the given object is not of a suitable type. Despite not enforcing static typing, Python is strongly typed, forbidding nonsense operations (for example, adding a number to a string) rather than silently attempting to make sense of them.

Types

Type Description Syntax Example
strString (computer science)

In computer programming and some branches of mathematics, strings are sequences of various simple objects....
, unicodeUnicode

Unicode is an industry standard designed to allow text and symbols from all of the writing systems of the world to be consis...
An immutableImmutable object

In object-oriented computer programming, an immutable object is an object whose state cannot be modified after it is created...
 sequence of characters
'Wikipedia', u'Wikipedia'
list MutableImmutable object

In object-oriented computer programming, an immutable object is an object whose state cannot be modified after it is created...
, can contain mixed types
[4.0, 'string', True]
tupleTuple

In mathematics, a tuple is a finite sequence of objects, each of a specified type....
ImmutableImmutable object

In object-oriented computer programming, an immutable object is an object whose state cannot be modified after it is created...
, can contain mixed types
(4.0, 'string', True)
setSet (computer science)

In computer science, a set is a collection of certain values without any particular order, and no repeated values....
, frozenset
Unordered, contains no duplicates set([4.0, 'string', True])
frozenset([4.0, 'string', True])
dictAssociative array

An associative array is an abstract data type composed of a collection of keys and a collection of values, where each key is...
Group of key and value pairs
intInteger (computer science)

In computer science, the term integer is used to refer to any data type which can represent some subset of the mathematical ...
A fixed precision number
(will be transparently expanded to an unlimited precision long, when it overflows the storage for an integer.
42
2147483648L
floatFloating point

Floating-point is a means of representing real numbers in terms of digits or bits in a computer or calculator, similar to ho...
A real numberReal number

In mathematics, the set of real numbers, denoted R, is the set of all rational numbers and irrational numbers....
3.1415927
complexComplex number

In mathematics, a complex number is a number of the form ...
A complex numberComplex number

In mathematics, a complex number is a number of the form ...
 with real number and imaginary parts
3+2j
bool truth valueTrue or False


Python also allows programmers to define their own types. This is done using classClass (computer science)

In object-oriented programming, classes are used to group related variables and functions....
es, which are most often used for an object-oriented style of programming. New instances of classes are constructed by calling the class (eg, FooClass()), and the classes themselves are instances of the class type (itself an instance of itself), allowing metaprogrammingMetaprogramming

Metaprogramming is the writing of programs that write or manipulate other programs as their data or that do part of the work...
 and reflection.

Implementations

The mainstream Python implementation, also known as CPythonFacts About CPython

CPython is the default, most-widely used implementation of the Python programming language....
, is written in CC (programming language)

The C programming language is a general-purpose, procedural, imperative computer programming language developed in the earl...
 meeting the C89 standard,. CPython compiles the Python program into intermediate byte code, which is then executed by the virtual machine. It is distributed with a large standard library written in a mixture of C and Python. CPython ships in versions for many platforms, including Microsoft WindowsMicrosoft Windows

Microsoft Windows is a family of operating systems by Microsoft....
 and most modern Unix-likeUnix-like

A "Unix-like" operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to...
 systems. CPython was intended from almost its very conception to be cross-platform; its use and development on esoteric platforms such as Amoeba, alongside more conventional ones like UnixUnix

Unix or UNIX is a computer operating system originally developed in the 1960s and 1970s by a group of AT&T Bell Labs e...
, or MacintoshMacintosh

The Macintosh, or Mac, is a line of personal computers designed, developed, manufactured, and marketed by Apple Comput...
 has greatly helped in this regard.

Stackless PythonStackless Python

Stackless Python, or Stackless, is an experimental implementation of the Python programming language, so named because...
 is a significant fork of CPython that implements microthreadMicrothread Summary

Microthreads are small code fragments that can be run concurrently to gain increased performance in microprocessors....
s; it does not use the C memory stack and will be better suited for use on microcontrollers or other limited resource platforms. It can be expected to run on approximately the same platforms that CPython runs on.

JythonJython

Jython, formerly known as JPython, is an implementation of the Python programming language written in Java....
 compiles the Python program into Java byte code, which can then be executed by every Java Virtual MachineJava Virtual Machine

A Java Virtual Machine , originally developed by Sun Microsystems, is a virtual machine that executes Java bytecode....
 implementation. This also enables the utilization of Java class library functions from the Python program. IronPythonIronPython

IronPython is an implementation of the Python programming language, targeting .NET and Mono, created by Jim Hugunin....
 follows a similar approach in order to run Python programs on the .NET Common Language RuntimeCommon Language Runtime

Common Language Runtime is the name chosen by Microsoft for the virtual machine component of their .NET initiative....
.

PyPyPyPy Summary

PyPy is a reimplementation of Python written in Python itself, flexible and easy to experiment with....
 is an experimental self-hostingSelf-hosting

Self-hosting refers to the use of a computer program as part of the toolchain or operating system that produces new versions...
 implementation of Python, written in Python, that can output several types of bytecodeFacts About Bytecode

Bytecode is an intermediate code more abstract than machine code....
, object code and intermediate languageIntermediate language

In computer science, an intermediate language is the language of an abstract machine designed to aid in the analysis of comp...
s.

Several programs exist to package the Python interpreter with application programs (or scripts) as standalone UNIX, Linux, Windows or Mac OS X executables, including , a pure Python utility that ships with Python, or , , and , all of which are available separately. Many third-party libraries for Python (and even some first-party ones) are only available on Windows, Linux, BSD, and Mac OS X.

In 2005 NokiaNokia

Nokia Corporation is the world's largest manufacturer of mobile telephones , with a global market share of approximately 34...
 released a Python interpreter for the Series 60 mobile phoneMobile phone

A mobile or cell phone is a long-range, portable electronic device for personal telecommunications over long dis...
s called PyS60. It includes many of the modules from the CPython implementations, but also some additional modules for integration with the Symbian operating system. This project has been kept up to date to run on all variants of the S60 platform and there are several third party modules available such as and .

(??) is a Python programming language using Chinese language lexicon. Besides reserved words and variable names, most data type operations can be coded in Chinese as well.

Interpretational semantics


Most Python implementations (including CPython, the primary implementation) can function as a command line interpreterCommand line interpreter

A command line interpreter is a computer program which reads lines of text that the user types and interprets them in the co...
, for which the user enters statements sequentially and receives the results immediately. In short, Python acts as a shellShell (computing) Overview

In computing, a shell is a piece of software that provides an interface for users....
. While the semantics of the other modes of execution (bytecode compilation, or compilation to native code) preserve the sequential semantics, they offer a speed boost at the cost of interactivity, so they are usually only used outside of a command-line interaction (eg, when importing a module).

Other shells add capabilities beyond those in the basic interpreter, including IDLEIDLE (Python)

name = IDLE| logo =...
 and IPythonIPython

IPython is an interactive shell for the Python programming language that offers enhanced introspection, additional shell syn...
. While generally following the visual style of the Python shell, they implement features like auto-completion, retention of session state, and syntax highlighting.

Some implementations can compile not only to bytecode to, but can turn Python code into machine codeMachine code

Machine code or machine language is a system of instructions and data directly understandable by a computer's central ...
. So far, this has only been done for restricted subsets of Python. PyPy takes this approach, naming its restricted compilable version of Python RPython. Shed SkinShed Skin

name = Shed Skin| class = stub| logo = ...
 is a similar experimental compilerCompiler

A compiler is a computer program that translates text written in a computer language into another computer language ....
.

PsycoPsyco

Psyco is a specializing compiler / just-in-time compiler for Python....
 is a specialising just in time compiler which transforms bytecode to machine code at runtime. The produced code is specialised for certain data types and is faster than standard Python code, sometimes much much faster. Psyco is compatible with all Python code, not only a subset.

Standard library

Python has a large standard library, commonly cited as one of Python's greatest strengths, providing pre-written tools suited to many tasks. This is deliberate and has been described as a "batteries included" Python philosophy. The modules of the standard library can be augmented with custom modules written in either C or Python. Recently, Boost C++ Libraries includes a library, Boost.Python, to enable interoperability between C++ and Python. Because of the wide variety of tools provided by the standard library, combined with the ability to use a lower-level language such as C and C++, which is already capable of interfacing between other libraries, Python can be a powerful glue languageGlue language Summary

A glue language is a programming language used for connecting software components together....
 between languages and tools.

The standard library is particularly well tailored to writing Internet-facing applications, with a large number of standard formats and protocols (such as MIMEMIME

Multipurpose Internet Mail Extensions is an Internet Standard that extends the format of e-mail to support text in characte...
 and HTTPHypertext Transfer Protocol

Hypertext Transfer Protocol is a method used to transfer or convey information on the World Wide Web....
) already supported. Modules for creating graphical user interfaceGraphical user interface

A graphical user interface , is a particular case of user interface for interacting with a computer which employs graphical ...
s, connecting to relational databaseRelational database

A relational database is a database that conforms to the relational model....
s, arithmetic with arbitrary precision decimals, and manipulating regular expressionFacts About Regular expression

A regular expression is a string that describes or matches a set of strings, according to certain syntax rules....
s are also included. Python also includes a unit testing framework for creating test suites.

Some parts of the standard library are covered by specifications (for example, the WSGI implementation wsgiref follows ), but the majority of the modules are not. They are specified by their code, internal documentation, and test suite (if supplied). However, because most of the standard library is cross-platform Python code, there are only a few modules must be altered or completely rewritten by alternative implementations.

Programming philosophy

Python is a multi-paradigm programming languageMulti-paradigm programming language

A multiparadigm programming language is a programming language that supports more than one programming paradigm....
. This means that, rather than forcing programmers to adopt a particular style of programming, it permits several styles: object oriented and structured programmingStructured programming

Structured programming can be seen as a subset or subdiscipline of procedural programming, one of the major programming para...
 are fully supported, and there are a number of language features which support functional programmingFunctional programming

Functional programming is a programming paradigm that conceives computation as the evaluation of mathematical functions and ...
 and aspect-oriented programmingAspect-oriented programming

In software engineering, the programming paradigms of aspect-oriented programming, and aspect-oriented software developme...
. Many other paradigms are supported using extensions, such as and which allow Design by ContractDesign by contract

Design by contract, DBC or Programming by contract is a methodology for designing computer software....
. Python uses dynamic typing and a combination of reference countingReference counting

In computer science, reference counting is a technique of storing the number of references, pointers, or handles to a resour...
 and a cycle detecting garbage collectorGarbage collection (computer science)

In computer science, garbage collection is a form of automatic memory management....
 for memory managementMemory management

Memory management is the act of managing computer memory....
. An important feature of Python is dynamic name resolutionName resolution

In computer science, name resolution is the process of finding the entity that an identifier used in a certain context refer...
, which binds method and variable names during program execution (also known as late binding).

Another target of the language's design is ease of extensibility, rather than having everything built into the language core. New built-in modules are easily written in CC (programming language)

The C programming language is a general-purpose, procedural, imperative computer programming language developed in the earl...
 or C++Facts About C++

C++ is a general-purpose, high-level programming language with low-level facilities....
. Python can also be used as an extension language for existing modules and applications that need a programmable interface. This design, of a small core language with a large standard library and an easily-extensible interpreter, was intended by van Rossum from the very start, due to his frustrations with ABC, which espoused the opposite mindset.

The design of Python offers limited support for functional programmingFunctional programming

Functional programming is a programming paradigm that conceives computation as the evaluation of mathematical functions and ...
 in the LispLisp programming language

Lisp is a family of computer programming languages with a long history and a distinctive fully-parenthesized syntax....
 tradition. However, there are significant parallels between the philosophy of Python and that of minimalist Lisp-family languages such as Scheme. The library has two modules (itertools and functools) that implement proven functional tools borrowed from HaskellHaskell (programming language) Overview

Haskell is a standardized pure functional programming language with non-strict semantics, named after the logician Haskell C...
 and Standard MLStandard ML

Standard ML is a general-purpose, modular, functional programming language with compile-time type checking and type inferenc...
.

While offering choice in coding methodology, the Python philosophy rejects exuberant syntax, such as in PerlPerl

Perl, also Practical Extraction and Report Language is a dynamic procedural programming language designed by Larry Wa...
, in favor of a sparser, less cluttered one. As with Perl, Python's developers expressly promote a particular "culture" or ideology based on what they want the language to be, favoring language forms they see as "beautiful", "explicit" and "simple". As Alex MartelliAlex Martelli

Alex Martelli is a member of the Python Software Foundation and works, as of 2006, as "Über Tech Lead" for Google, Inc., in ...
 put it in his Python Cookbook (2nd ed., p.230): "To describe something as clever is NOT considered a compliment in the Python culture." Python's philosophy rejects the Perl "there is more than one way to do itThere is more than one way to do it

There is more than one way to do it is a Perl motto....
" approach to language design in favor of "there should be one—and preferably only one—obvious way to do it".

Python eschews premature optimizationOptimization (computer science)

In computing, optimization is the process of modifying a system to improve its efficiency....
, and moreover, rejects patches to non-critical parts of CPython which would offer a marginal increase in speed at the cost of clarity. It is sometimes described as 'slow'. However, most problems are not speed critical, and as computer hardware continues to become exponentially faster, languages do have more hardware resources available. When speed is a problem, Python programmers tend to try to optimize bottlenecks by algorithm improvements or data structure changes, by using a JIT compiler such as Psyco, or by rewriting the time-critical functions in "closer to the metal" languages such as C.

Influences on other languages

Python's design and philosophy have influenced several programming languages:

  • Boo's Python heritage is more explicit — it also uses indentation, a similar syntax, and a similar object model. Boo, however, uses static typing and is closely integrated with the .NET framework.NET Framework

    The Microsoft .NET Framework is a software component which can be added to the Microsoft Windows operating system....
    .
  • CobraCobra (programming language from Cobra Language LLC)

    Cobra is an object-oriented programming language produced by Cobra Language LLC....
     is also similar to Python, using indentation for blocks. It offers optional static typing and generates code designed for .NET/Mono. Cobra directly supports design-by-contractDesign by contract

    Design by contract, DBC or Programming by contract is a methodology for designing computer software....
     contracts.
  • ECMAScriptECMAScript

    ECMAScript is a scripting programming language, standardized by Ecma International in the ECMA-262 specification....
     (commonly called Javascript) borrowed iteratorsIterator

    In computer science, an iterator is an object which allows a programmer to traverse through all the elements of a collection...
    , generatorsGenerator (computer science)

    In computer science, a generator is a special routine that can be used to control the iteration behaviour of a loop....
     and list comprehensionList comprehension

    In programming languages, list comprehension is a construct for list processing, analogous to the set-builder notation, ...
    s from Python.
  • Groovy was motivated by the desire to bring the Python design philosophy to JavaJava (programming language)

    Java is an object-oriented programming language developed by James Gosling and colleagues at Sun Microsystems in the early 1...
    .


Python's development practices have also been emulated by other languages. The practice of requiring a document describing the rationale for, and issues surrounding, a change to the language (ie, a PEP) is also used in TclTcl

Tcl is a scripting language created by John Ousterhout....
 because of Python's influence.

See also

  • Alphabetical list of programming languagesAlphabetical list of programming languages

    The list of programming languages consists of all notable programming languages in existence, currently or since the dawn of...
  • Comparison of computer shellsComparison of computer shells

    A shell is a computer program which interacts with the userland and subsequently the kernel of an operating system....
  • Comparison of programming languagesComparison of programming languages

    Programming languages are used for controlling the behavior of a machine....
  • List of applications written in PythonList of applications written in Python Overview

    This is a list of applications written in Python....
  • List of integrated development environments for Python
  • Guido van RobotGuido van Robot

    Guido van Robot is an educational tool to help students learn the Python programming language, named after the creator of P...
  • Scripting languageScripting language

    Scripting languages are computer programming languages created to shorten the traditional edit-compile-link-run process....


External links