Python
Python is an interpreted, high-level, general-purpose
programming language. Created by Guido van Rossum and first released in 1991, Python's design philosophy
emphasizes code readability with its notable use of significant whitespace. Its language constructs and
object-oriented approach aim to help programmers write clear, logical code for small and large-scale
projects.
Python is dynamically typed and garbage-collected. It supports multiple programming paradigms, including
structured (particularly, procedural), object-oriented, and functional programming. Python is often
described as a "batteries included" language due to its comprehensive standard library.
Python was conceived in the late 1980s as a successor to the ABC language. Python 2.0, released in 2000,
introduced features like list comprehensions and a garbage collection system with reference counting.
Python 3.0, released in 2008, was a major revision of the language that is not completely
backward-compatible, and much Python 2 code does not run unmodified on Python 3.The Python 2 language
was officially discontinued in 2020 (first planned for 2015), and "Python 2.7.18
is the last Python 2.7 release and therefore the last Python 2 release."
History
Python was conceived in the late 1980s by Guido van Rossum at Centrum Wiskunde & Informatica (CWI)
in the Netherlands as a successor to the ABC language (itself inspired by SETL),capable of
exception handling and interfacing with the Amoeba operating system.Its implementation began in
December 1989.Van Rossum shouldered sole responsibility for the project, as the lead developer,
until 12 July 2018, when he announced his "permanent vacation" from his responsibilities as Python's
Benevolent Dictator For Life, a title the Python community bestowed upon him to reflect his long-term
commitment as the project's chief decision-maker.He now shares his leadership as a member of a
five-person steering council.
In January 2019, active Python core developers elected Brett Cannon, Nick Coghlan, Barry Warsaw,
Carol Willing and Van Rossum to a five-member "Steering Council" to
lead the project.Python 2.0 was released on 16 October 2000 with many major new features, including
a cycle-detecting
garbage collector and support for Unicode.Python 3.0 was released on 3 December 2008. It was a major
revision of the language that is not
completely backward-compatible.Many of its major features were backported to Python 2.6. and
2.7.x version series.
Releases of Python 3 include the 2 to 3 utility, which automates (at least partially) the
translation of Python 2 code to Python 3.Python 2.7's end-of-life date was initially set at 2015
then postponed to 2020 out of concern that a
large body of existing code could not easily be forward-ported to Python 3.
Features and philosophy
In January 2019, active Python core developers elected Brett Cannon, Nick Coghlan, Barry Warsaw,
Carol Willing and Van Rossum to a five-member "Steering Council" to
lead the project.Python 2.0 was released on 16 October 2000 with many major new features, including
a cycle-detecting
garbage collector and support for Unicode.Python 3.0 was released on 3 December 2008. It was a major
revision of the language that is not
completely backward-compatible.Many of its major features were backported to Python 2.6. and
2.7.x version series.
Releases of Python 3 include the 2 to 3 utility, which automates (at least partially) the
translation of Python 2 code to Python 3.Python 2.7's end-of-life date was initially set at 2015
then postponed to 2020 out of concern that a
large body of existing code could not easily be forward-ported to Python 3.
Rather than having all of its functionality built into its core, Python was designed to be highly
extensible. This compact modularity has made it particularly popular as a means of adding
programmable interfaces to existing applications. Van Rossum's vision of a small core language with
a large standard library and easily extensible interpreter stemmed from his frustrations with ABC,
which espoused the opposite approach.Python strives for a simpler, less-cluttered syntax and grammar
while giving developers a choice in their coding methodology.
In contrast to Perl's "there is more than one way to do it" motto, Python embraces a "there should
be one—and preferably only one—obvious way to do it" design philosophy.
Alex Martelli, a Fellow at the Python Software Foundation and Python book author, writes that "To
describe something as 'clever' is not considered a compliment in the Python culture."Python's
developers strive to avoid premature optimization, and reject patches to non-critical parts
of the CPython reference implementation that would offer marginal increases in speed at the cost of
clarity.
When speed is important, a Python programmer can move time-critical functions to extension modules
written in languages such as C, or use PyPy, a just-in-time compiler. Cython is
also available, which translates a Python script into C and makes direct C-level API calls into the
Python interpreter.An important goal of Python's developers is keeping it fun to use. This is
reflected in the language's name—a tribute to the British comedy group Monty Python—and in
occasionally playful
approaches to tutorials and reference materials, such as examples that refer to spam and eggs (from
a famous Monty Python sketch) instead of the standard foo and bar.
Syntax and semantics
Python is meant to be an easily readable language. Its formatting is visually uncluttered, and it
often uses English keywords where other languages use punctuation. Unlike many other languages, it
does not use curly brackets to delimit blocks, and semicolons after statements are optional. It has
fewer syntactic exceptions and special cases than C or Pascal.
Python uses whitespace indentation, rather than curly brackets or keywords, to delimit blocks. An
increase in indentation comes after certain statements; a decrease in indentation signifies the end
of the current block.Thus, the program's visual structure accurately represents the program's
semantic structure.This feature is sometimes termed the off-side rule, which some other
languages share, but in most languages indentation doesn't have any semantic meaning.Despite being
dynamically typed, Python is strongly typed, forbidding operations that are not well-defined (for
example, adding a number to a string) rather than silently attempting to make sense of them.
Python allows programmers to define their own types using classes, which are most often used for
object-oriented programming. New instances of classes are constructed by calling the class (for
example, SpamClass() or EggsClass()), and the classes are instances of the metaclass type (itself an
instance of itself), allowing metaprogramming and reflection.
Before version 3.0, Python had two kinds of classes: old-style and new-style.The syntax of both
styles is the same, the difference being whether the class object is inherited from, directly or
indirectly (all new-style classes inherit from object and are instances of type). In versions of
Python 2 from Python 2.2 onwards, both kinds of classes can be used. Old-style classes were
eliminated in Python 3.0.
The long term plan is to support gradual typing and from Python 3.5, the syntax of the language
allows specifying static types but they are not checked in the default implementation, CPython. An
experimental optional static type checker named mypy supports compile-time type checking.