Python (programming language) explained

Python is a general-purpose high-level programming language.[1] Its design philosophy emphasizes code readability.[2] Python's core syntax and semantics are minimalistic, while the standard library is large and comprehensive. Its use of whitespace as block delimiters is unusual among popular programming languages.

Python supports multiple programming paradigms (primarily object oriented, imperative, and functional) and features a fully dynamic type system and automatic memory management, similar to Perl, Ruby, Scheme, and Tcl. Like other dynamic languages, Python is often used as a scripting language.

The language has an open, community-based development model managed by the non-profit Python Software Foundation, which maintains the de facto standard definition of the language in CPython, the reference implementation.


See main article: History of the Python programming language. Python was conceived in the late 1980s[3] by Guido van Rossum at CWI in the Netherlands as a successor to the ABC programming language (itself inspired by SETL)[4] capable of exception handling and interfacing with the Amoeba operating system.[5] Van Rossum is Python's principal author, and his continuing central role in deciding the direction of Python is reflected in the title given to him by the Python community, Benevolent Dictator for Life (BDFL).

Python 2.0 was released on 16 October 2000, with many major new features including a full garbage collector and support for unicode. However, the most important change was to the development process itself, with a shift to a more transparent and community-backed process.[6] Python 3.0, a major, backwards-incompatible release, was released on 3 December 2008[7] after a long period of testing. Many of its major features have been backported to the backwards-compatible Python 2.6.[8]

Programming philosophy

Python is a multi-paradigm programming language. This means that, rather than forcing programmers to adopt a particular style of programming, it permits several styles: object oriented and structured programming are fully supported, and there are a number of language features which support functional programming and aspect-oriented programming. Many other paradigms are supported using extensions, such as pyDBC and Contracts for Python which allow Design by Contract. Python uses dynamic typing and a combination of reference counting and a cycle-detecting garbage collector for memory management. An important feature of Python is dynamic name resolution (late binding), which binds method and variable names during program execution.

Another aspect 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 C or C++. 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, because of his frustrations with ABC, which espoused the opposite mindset.[9]

The design of Python offers limited support for functional programming in the Lisp tradition. However, there are significant parallels between the philosophy of Python and those of minimalist Lisp-family languages such as Scheme. The library has two modules (itertools and functools) that implement proven functional tools borrowed from Haskell and Standard ML.[10]

While offering choice in coding methodology, the Python philosophy rejects exuberant syntax, such as in Perl, in favor of a sparser, less-cluttered grammar. 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 Martelli 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 it" approach to language design in favor of "there should be one—and preferably only one—obvious way to do it".[11]

Python eschews premature optimization, and moreover, rejects patches to non-critical parts of CPython which would offer a marginal increase in speed at the cost of clarity.[12] It is sometimes described as "slow".[13] However, most problems are not speed critical, and as computer hardware continues to become exponentially faster (Moore's Law), 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, using a JIT compiler such as Psyco, rewriting the time-critical functions in "closer to the metal" languages such as C, or by translating Python code to C code using tools like Cython.[14]

The core philosophy of the language is summarized by PEP 20 (The Zen of Python).


A common neologism in the Python community is pythonic, which can have a wide range of meanings related to program style. To say that a piece of code is pythonic is to say that it uses Python idioms well, that it is natural or shows fluency in the language. Likewise, to say of an interface or language feature that it is pythonic is to say that it works well with Python idioms, that its use meshes well with the rest of the language.

In contrast, a mark of unpythonic code is that it attempts to "write C++ (or Lisp, or Perl, or Java) code in Python"—that is, provides a rough transcription rather than an idiomatic translation of forms from another language. The concept of pythonicity is tightly bound to Python's minimalist philosophy of readability and avoiding the "there's more than one way to do it" approach. Unreadable code or incomprehensible idioms are unpythonic.

Users and admirers of Python—most especially those considered knowledgeable or experienced—are often referred to as Pythonists, Pythonistas, and Pythoneers.

The prefix Py can be used to show that something is related to Python. Examples of the use of this prefix in names of Python applications or libraries include Pygame, a binding of SDL to Python (commonly used to create games); PyS60, an implementation for the Symbian Series 60 Operating System; PyQt and PyGTK, which bind Qt and GTK, respectively, to Python; and PyPy, a Python implementation written in Python. The prefix is also used outside of naming software packages: the major Python conference is named PyCon.

An important goal of the Python developers is making Python fun to use. This is reflected in the origin of the name (based on the television series Monty Python's Flying Circus), in the common practice of using Monty Python references in example code, and in an occasionally playful approach to tutorials and reference materials.[15] For example, the metasyntactic variables often used in Python literature are spam and eggs, instead of the traditional foo and bar.


See main article: Python software.

Python is often used as a scripting language for web applications, e.g. via mod_python for the Apache web server. With Web Server Gateway Interface a standard API has been developed to facilitate these applications. Web application frameworks or application servers like web2py, Zope, and Django support developers in the design and maintenance of complex applications.

Python has seen extensive use in the information security industry, including in exploit development.[16]

Notes and References

  1. Web site: What is Python Good For?. 2008-09-05. General Python FAQ. Python Foundation.
  2. Web site: What is Python? Executive Summary. Python Foundation. Python documentation. 2007-03-21.
  3. Web site: The Making of Python. 2007-03-22. Artima Developer.
  5. Web site: Why was Python created in the first place?. Python FAQ. 2007-03-22.
  6. Web site: What's New in Python 2.0. A.M. Kuchling and Moshe Zadka. 2007-03-22.
  7. Python 3.0 release
  8. PEP 3000
  9. Web site: The Making of Python. 2007-03-22. Artima Developer.
  10. Web site: 6.5 itertools - Functions creating iterators for efficient looping. 2008-11-24.
  11. Web site: PEP 20 - The Zen of Python. 2008-11-24.
  12. Python Culture
  13. Python is... slow? — Peter Bowyer’s weblog
  14. Python Patterns - An Optimization Anecdote
  15. Python Tutorial
  16. Products and discussion of this use of Python include Web site: IMMUNITY : Knowing You're Secure. 2008-11-24. ; CORE Security Technologies' open source software repository; Web site: Wapiti - Web application security auditor. 2008-11-24. ; Web site: TAOF - - Home. 2008-11-24. ; Web site: [Dailydave] RE: Network Exploitation Tools aka Exploitation Engines | |date= |accessdate=2008-11-24}].