Pywikibot Introduction

Pywikibot is a set of python functions which make it much much easier to make automated edits on mediawiki.

**Warning**: You are accountable for every edit you or your python script makes. Be careful and don't get banned!

In [2]:
import pywikibot

1. Using a mediawiki site

The first thing pywikibot needs to know, is which mediawiki website to target. There are many official sites like,,,,,, etc. And each has their own versions with different languages like,, etc.

The default website seen on PAWS is the To check the website out, go on to

In [3]:
testwiki = pywikibot.Site()
APISite("test", "wikipedia")

A mediawiki website has 2 parts which are important. The code and the family. The pywikibot API supports a LOT of official families and codes, and can also add a local instance or a personal deployment of mediawiki.

The family tells pywikibot which type of mediawiki site should be used, and it can read and write data specific to the family. Examples of family are: wikipedia, wikitionary, wikisource, etc.

The code tells pywikibot which variant of the family should be used. Common examples of codes are: en, es, ml, etc. The code depends on the family though. For example, the "commons" family has only the "commons" code.

In [4]:
enwiki = pywikibot.Site(code="en", fam="wikipedia")
APISite("en", "wikipedia")
In [5]:
commons = pywikibot.Site(code="commons", fam="commons")
APISite("commons", "commons")
In [6]:
wikidata = pywikibot.Site(code="wikidata", fam="wikidata")
DataSite("wikidata", "wikidata")
In [7]:
testwikidata = pywikibot.Site(code="test", fam="wikidata")
DataSite("test", "wikidata")

2. Logging in

In the PAWS interface, the user is set by default to the user account that has been used to login to PAWS. But in a local script, we would need to modify the file to add the username and password. We will see this later.

We tell pywikibot to login with the login() function. Then we check which user has been used to login:

In [8]:
print('Logged in user is:', testwiki.user())
Logged in user is: Anoopchandu18

3. Reading data on Pages

To pull data from pywikibot, we use the Page class which holds information about a page from the mediawiki website.

First, we create a Page object using the name of the page. Here, we use the page "User:AbdealiJK/Pywikibot_Tutorial" as an example:

In [12]:
demo_page = pywikibot.Page(testwiki, 'User:Anoopchandu18')

Now we use the class to fetch other information about the page. For example, to get the text of the page:

In [10]:
Hi !

This is a example page for the pywikibot tutorial users to see.

You can get a lot of other information about the page by using various helper functions provided by pywikibot:

In [13]:
print("Check if page exists:", demo_page.exists())
print("Title of the page:", demo_page.title())
print("Contributors of the page:", demo_page.contributors())
print("Last edit made on page:", demo_page.editTime())
print("Full URL to page:", demo_page.full_url())
Check if page exists: True
Title of the page: User:Anoopchandu18
Contributors of the page: Counter({'Anoopchandu18': 2})
Last edit made on page: 2016-09-18T04:23:26Z
Full URL to page:

4. Writing data to Pages

In general use the test wikipedia website for writing data, and ensure that you make changes in your User space (pages starting with User:<Your user name> as these are meant for your personal usage like testing these scripts :)

For example, let's create the object for your personal Sandbox page on test wiki:

In [19]:
sandbox = pywikibot.Page(testwiki, 'User:' + testwiki.user() + '/Sandbox')

Here, let's try writing some wiki markup to the page. For example, let's try making your profile !

Note: To get more information about the wikimarkup visit Help:Wiki markup

In [20]:
sandbox.text ="""
== About Me ==


My name is '''{name}'''.

I am from {hometown} and am learning how to use pywikibot !

This page has been written using the pywikibot API.
""".format(name="Anoop Chandu",
Page [[User:Anoopchandu18/Sandbox]] saved

Let's open up the webpage and see if our changes have been added there.

Using Jupyter and IPython, we can even embed the webpage into the notebook:

In [21]:
from IPython.display import IFrame
IFrame(sandbox.full_url(), width="100%", height="400px")

5. Textlib functions

Once you can get content and save new content, there are many times you'd like to get a list of categories or templates from a mediawiki instance.

A category is a special namespace (Similar to the user space) which holds categories that are used to classify pages. For example the "Python (programming language)" page on wikipedia has the categories "Category:Class-based programming languages", "Category:Cross-platform free software", "Category:Dynamically typed programming languages" and so on.

To add a category to a page, a link to the category must be added to the medaiwiki page. Hence, something like [[Category:<name of category>]] should be added according to the wiki markup.

A template is a snippet of text which can be included into multiple other pages (Something like a #include or import). The wiki markup to add a template is {{<template name>}} and it can also take in arguments, for example {{<template name>|arg1|arg2}}.

In [30]:
python = pywikibot.Page(enwiki, 'Python_(programming_language)')
[[en:Python (programming language)]]

Let's get a list of all categories added to the page:

In [34]:
[Category('Category:Articles with DMOZ links'),
 Category('Category:Class-based programming languages'),
 Category('Category:Cross-platform free software'),
 Category('Category:Dutch inventions'),
 Category('Category:Dynamically typed programming languages'),
 Category('Category:Educational programming languages'),
 Category('Category:Good articles'),
 Category('Category:High-level programming languages'),
 Category('Category:Object-oriented programming languages'),
 Category('Category:Programming languages created in 1991'),
 Category('Category:Python (programming language)'),
 Category('Category:Scripting languages'),
 Category('Category:Text-oriented programming languages'),
 Category('Category:Use dmy dates from August 2015'),
 Category('Category:Wikipedia articles needing page number citations from January 2012'),
 Category('Category:Wikipedia articles with GND identifiers'),
 Category('Category:Wikipedia articles with LCCN identifiers')]

The textlib functions help to modify the text content on the page for specific needs like adding or removing categories. Hence, it has it's parsers which read through the text and pull out all the category links it finds based on the wiki markup.

In [ ]:
In [39]:
print("Text categories in page:", len(pywikibot.textlib.getCategoryLinks(python.text)))
print("All categories associated with page:", len(list(python.categories())))
Text categories in page: 11
All categories associated with page: 17

Let's try removing a category using the textlib functions:

In [41]:
new_text = pywikibot.textlib.removeCategoryLinks(python.text)
print("List of categories after the remove function:", pywikibot.textlib.getCategoryLinks(new_text))
{{About|the programming language|the genus and other uses|Python (disambiguation)}}
{{Use dmy dates|date=August 2015}}
{{Infobox programming language
|name                   = Python
|logo                   = Python logo and wordmark.svg
|logo size              = 260px
|paradigm               = [[multi-paradigm programming language|multi-paradigm]]: [[object-oriented programming|object-oriented]], [[imperative programming|imperative]], [[functional programming|functional]], [[procedural programming|procedural]], [[reflective programming|reflective]]
|released               = {{Start date and age|1991|02|20|df=yes}}<ref>{{cite web|url=|title=The History of Python: A Brief Timeline of Python|work=[[Blogger (service)|Blogger]]|date=2009-01-20|accessdate=2016-03-20}}</ref>
|designer               = [[Guido van Rossum]]
|developer              = [[Python Software Foundation]]
|latest release version = 3.5.2 / {{Start date and age|2016|06|27|df=yes}}<ref>{{cite web |url= |title=Python 3.5.2 and Python 3.4.5 are now available |website=Python Insider |publisher=The Python Core Developers |first=Larry |last=Hastings |date=2016-06-27 |accessdate=2016-06-28}}</ref><br>2.7.12 / {{Start date and age|2016|06|28|df=yes}}<ref>{{cite web |url= |title=Python 2.7.12 released |website=Python Insider |publisher=The Python Core Developers |first=Benjamin |last=Peterson |date=2016-06-28 |accessdate=2016-06-28}}</ref>
|latest preview version = 3.6.0b1 / {{Start date and age|2016|09|12df=yes}}<ref name="Python Release Python 3.6.0b1">{{cite web |url= |title=Python Release Python 3.6.0b1|publisher=Python Software Foundation|accessdate=17 September 2016}}</ref><!-- <br>2.7.9rc1 / {{Start date and age|2014|11|26|df=yes}}<ref>{{cite web |url= |title=Python 2.7.9 rc1 Release |publisher=Python Software Foundation |accessdate=26 November 2014}}</ref -->
|latest preview date    = 
|typing                 = [[duck typing|duck]], [[dynamic typing|dynamic]], [[strong typing|strong]], [[gradual typing|gradual]] (as of Python 3.5)<ref>{{cite web|url=|title=Type hinting for Python||date=24 December 2014|accessdate=5 May 2015}}</ref>
|implementations        = [[CPython]], [[IronPython]], [[Jython]], [[MicroPython]], [[PyPy]]
|dialects               = [[Cython]], [[RPython]], [[Stackless Python]]
|influenced             = [[Boo (programming language)|Boo]], [[Cobra (programming language)|Cobra]], [[CoffeeScript]],<ref>{{cite web|url=|title=CoffeeScript borrows chained comparisons from Python}}</ref> [[D (programming language)|D]], [[F Sharp (programming language)|F#]], [[Falcon (programming language)|Falcon]], [[Genie (programming language)|Genie]],<ref>{{cite web 
|title=Genie Language - A brief guide 
|accessdate=2015-12-28}}</ref> [[Go (programming language)|Go]], [[Groovy (programming language)|Groovy]], [[JavaScript]],<ref>{{cite web
|title = Perl and Python influences in JavaScript
|date= 24 February 2013
|accessdate= 15 May 2015}}</ref><ref>{{cite web
|title = Chapter 3: The Nature of JavaScript; Influences
|website=O'Reilly, Speaking JavaScript
|accessdate= 15 May 2015}}</ref> [[Julia (programming language)|Julia]],<ref name=Julia/> [[Nim (programming language)|Nim]], [[Ruby (programming language)|Ruby]],<ref name="bini"/> [[Swift (programming language)|Swift]],<ref name="lattner2014">{{cite web|url=|title=Chris Lattner's Homepage|last=Lattner|first=Chris|date=3 June 2014|accessdate=3 June 2014|publisher=Chris Lattner|quote=The Swift language is the product of tireless effort from a team of language experts, documentation gurus, compiler optimization ninjas, and an incredibly important internal dogfooding group who provided feedback to help refine and battle-test ideas. Of course, it also greatly benefited from the experiences hard-won by many other languages in the field, drawing ideas from Objective-C, Rust, Haskell, Ruby, Python, C#, CLU, and far too many others to list.}}</ref>
|operating system       = [[Cross-platform]]
|license                = [[Python Software Foundation License]]
|website                = {{URL|}}
|wikibooks              = Python Programming
|influenced_by          = [[ABC (programming language)|ABC]],<ref name="faq-created"/> [[ALGOL 68]],<ref name="98-interview"/> [[C (programming language)|C]],<ref name="AutoNT-1"/> [[C++]],<ref name="classmix"/> [[Dylan (programming language)|Dylan]],<ref name="AutoNT-2"/> [[Haskell (programming language)|Haskell]],<ref name="AutoNT-3"/> [[Icon (programming language)|Icon]],<ref name="AutoNT-4"/> [[Java (programming language)|Java]],<ref name="AutoNT-5"/> [[Lisp (programming language)|Lisp]],<ref name="AutoNT-6"/> [[Modula-3|Modula&#8209;3]],<ref name="classmix" /> [[Perl]]
|file ext               = .py, .pyc, .pyd, .pyo,<ref>File extension .pyo will be removed in Python 3.5. See [ PEP 0488]</ref> {{notatypo|.pyw}}, .pyz<ref>{{cite web|url=|last=Holth|first=Moore|date=30 March 2014|accessdate=12 Nov 2015|title=PEP 0441 -- Improving Python ZIP Application Support}}</ref>

'''Python''' is a widely used [[High-level programming language|high-level]], [[General-purpose programming language|general-purpose]], [[Interpreter (computing)|interpreted]], [[dynamic programming language]].<ref name="AutoNT-34" /><ref>{{cite web|url=|title=The RedMonk Programming Language Rankings: June 2015 – tecosystems||date=1 July 2015|accessdate=10 September 2015}}</ref> Its design philosophy emphasizes code [[readability]], and its syntax allows programmers to express concepts in fewer [[source lines of code|lines of code]] than possible in languages such as [[C++]] or [[Java (programming language)|Java]].<ref name="Summerfield">{{cite book |title=Rapid GUI Programming with Python and Qt |last=Summerfield |first=Mark |quote=Python is a very expressive language, which means that we can usually write far fewer lines of Python code than would be required for an equivalent application written in, say, C++ or Java}}</ref><ref>{{cite book|url=|title=Code Complete, p. 100|isbn=9780735636972|last1=McConnell|first1=Steve|date=30 November 2009}}</ref> The language provides constructs intended to enable writing clear programs on both a [[Programming in the large and programming in the small|small and large scale]].<ref name="AutoNT-7" />

Python supports multiple [[programming paradigm]]s, including [[object-oriented programming|object-oriented]], [[imperative programming|imperative]] and [[functional programming]] or [[procedural programming|procedural]] styles. It features a [[dynamic type]] system and automatic [[memory management]] and has a large and comprehensive [[standard library]].<ref name="About" />

Python interpreters are available for many [[operating system]]s, allowing Python code to run on a wide variety of systems. Using [[Third-party software component|third-party]] tools, such as [[Py2exe]] or Pyinstaller,<ref>{{cite web |title=PyInstaller Home Page |url=|accessdate=27 January 2014}}</ref> Python code can be packaged into stand-alone executable programs for some of the most popular operating systems, so Python-based software can be distributed to, and used on, those environments with no need to install a Python interpreter.

[[CPython]], the [[reference implementation]] of Python, is [[free and open-source software]] and has a community-based development model, as do nearly all of its variant implementations. CPython is managed by the non-profit [[Python Software Foundation]].

== History ==
[[File:Guido van Rossum OSCON 2006.jpg|thumb|[[Guido van Rossum]], the creator of Python]]
{{Main article|History of Python}}

Python was conceived in the late 1980s,<ref name="venners-interview-pt-1" /> and its implementation began in December 1989<ref name="timeline-of-python" /> by [[Guido van Rossum]] at [[Centrum Wiskunde & Informatica]] (CWI) in the [[Netherlands]] as a successor to the [[ABC (programming language)|ABC language]] (itself inspired by [[SETL]])<ref name="AutoNT-12" /> capable of [[exception handling]] and interfacing with the operating system [[Amoeba (operating system)|Amoeba]].<ref name="faq-created" /> 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).

About the origin of Python, Van Rossum wrote in 1996:<ref>{{cite web|url=|title=Foreword for "Programming Python" (1st ed.)|last=van Rossum|first=Guido|date=1996|accessdate=10 July 2014}}</ref>

{{quote|Over six years ago, in December 1989, I was looking for a "hobby" programming project that would keep me occupied during the week around Christmas. My office ... would be closed, but I had a home computer, and not much else on my hands. I decided to write an interpreter for the new scripting language I had been thinking about lately: a descendant of [[ABC (programming language)|ABC]] that would appeal to [[Unix]]/[[C (programming language)|C]] [[Hacker (programmer subculture)|hackers]]. I chose Python as a working title for the project, being in a slightly irreverent mood (and a big fan of ''[[Monty Python's Flying Circus]]'').}}

Python 2.0 was released on 16 October 2000 and had many major new features, including a cycle-detecting [[garbage collection (computer science)|garbage collector]] and support for [[Unicode]]. With this release the development process was changed and became more transparent and community-backed.<ref name="newin-2.0" />

Python 3.0 (which early in its development was commonly referred to as Python 3000 or py3k), a major, backwards-incompatible release, was released on 3 December 2008<ref name="3.0-release" /> after a long period of testing. Many of its major features have been [[backporting|backported]] to the backwards-compatible Python 2.6.x<ref name="pep-3000" /> and 2.7.x version series.

== Features and philosophy ==
Python is a [[multi-paradigm programming language]]: [[object-oriented programming]] and [[structured programming]] are fully supported, and many language features support [[functional programming]] and [[aspect-oriented programming]] (including by [[metaprogramming]]<ref name="AutoNT-13" /> and [[metaobject]]s (magic methods)).<ref name="AutoNT-14" /> Many other paradigms are supported via extensions, including [[design by contract]]<ref name="AutoNT-15" /><ref name="AutoNT-16" /> and [[logic programming]].<ref name="AutoNT-17" />

Python uses [[dynamic typing]] and a mix of [[reference counting]] and a cycle-detecting garbage collector for [[memory management]]. An important feature of Python is dynamic [[Name resolution (programming languages)|name resolution]] ([[late binding]]), which binds method and variable names during program execution.

The design of Python offers some support for [[functional programming]] in the [[Lisp (programming language)|Lisp]] tradition. The language has map(), reduce() and filter() functions; [[list comprehension]]s, [[Associative array|dictionaries]], and sets; and [[Generator (computer programming)|generator]] expressions.<ref name="AutoNT-59"/> The standard library has two modules (itertools and functools) that implement functional tools borrowed from [[Haskell (programming language)|Haskell]] and [[Standard ML]].<ref name="AutoNT-18" />

The core philosophy of the language is summarized by the document ''The [[Zen of Python]]'' (''PEP 20''), which includes [[aphorism]]s such as:<ref name="PEP20" />

* Beautiful is better than ugly
* Explicit is better than implicit
* Simple is better than complex
* Complex is better than complicated
* Readability counts

Rather than requiring all desired functionality to be built into the language's core, Python was designed to be highly extensible. Python can also be embedded in existing 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 start because of his frustrations with [[ABC (programming language)|ABC]], which espoused the opposite mindset.<ref name="venners-interview-pt-1" />

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 [[Alex Martelli]] put it: "To describe something as clever is ''not'' considered a compliment in the Python culture."<ref name="AutoNT-19" /> 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".<ref name="PEP20" />

Python's developers strive to avoid [[premature optimization]], and moreover, reject patches to non-critical parts of CPython that would offer a marginal increase in speed at the cost of clarity.<ref name="AutoNT-20" /> When speed is important, a Python programmer can move time-critical functions to extension modules written in languages such as C, or try using [[PyPy]], a [[just-in-time compilation|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 making it fun to use. This is reflected in the origin of the name, which comes from [[Monty Python]],<ref>{{cite web|url=|title=General Python FAQ - Why is it called Python?}}</ref> and in an occasionally playful approach to tutorials and reference materials, such as using examples that refer to spam and eggs instead of the standard [[Foobar|foo and bar]].<ref>{{cite web|url=|title=15 Ways Python Is a Powerful Force on the Web}}</ref><ref>{{cite web|url=|title=pprint - Data pretty printer - Python Documentation}}</ref>

A common [[neologism]] in the Python community is ''pythonic'', which can have a wide range of meanings related to program style. To say that code is pythonic is to say that it uses Python idioms well, that it is natural or shows fluency in the language, that it conforms with Python's minimalist philosophy and emphasis on readability. In contrast, code that is difficult to understand or reads like a rough transcription from another programming language is called ''unpythonic''.

Users and admirers of Python, especially those considered knowledgeable or experienced, are often referred to as ''Pythonists'', ''Pythonistas'', and ''Pythoneers''.<ref name="AutoNT-27" /><ref name="AutoNT-25" />

== Syntax and semantics ==
{{Main article|Python syntax and semantics}}

Python is intended to be a highly readable language. It is designed to have an uncluttered visual layout, often using English keywords where other languages use punctuation. Further, Python has fewer syntactic exceptions and special cases than [[C (programming language)|C]] or [[Pascal (programming language)|Pascal]].<ref name="AutoNT-52" />

=== Indentation ===
{{Main article|Python syntax and semantics#Indentation}}

Python uses [[whitespace character|whitespace]] indentation to delimit [[block (programming)|blocks]] - rather than [[curly bracket programming language|curly braces]] or keywords. An increase in indentation comes after certain statements; a decrease in indentation signifies the end of the current block.<ref name="AutoNT-53" /> This feature is also sometimes termed the [[off-side rule]].

=== Statements and control flow ===
Python's [[Statement (computer science)|statements]] include (among others):

* The assignment statement (token '=', the equals sign). This operates differently than in traditional [[imperative programming]] languages, and this fundamental mechanism (including the nature of Python's version of ''variables'') illuminates many other features of the language. Assignment in [[C (programming language)|C]], e.g., <code>x = 2</code>, translates to "typed variable name x receives a copy of numeric value 2". The (right-hand) value is copied into an [[Memory management#ALLOCATION|allocated storage location]] for which the (left-hand) [[Variable (computer science)|variable name]] is the symbolic address. The memory allocated to the variable is large enough (potentially quite large) for the declared [[Type system|type]]. In the simplest case of Python assignment, using the same example, <code>x = 2</code>, translates to "(generic) name x receives a [[Pointer (computer programming)|reference]] to a separate, dynamically allocated [[Object (computer science)|object]] of numeric (int) type of value 2." This is termed ''binding'' the name to the object. Since the name's storage location doesn't ''contain'' the indicated value, it is improper to call it a ''variable''. Names may be subsequently rebound at any time to objects of greatly varying types, including strings, procedures, complex objects with data and methods, etc. Successive assignments of a common value to multiple names, e.g., <code>x = 2</code>; <code>y = 2</code>; <code>z = 2</code> result in allocating storage to (at most) three names and one numeric object, to which all three names are bound. Since a name is a generic reference holder it is unreasonable to associate a fixed [[Type system|data type]] with it. However at a given time a name will be bound to ''some'' object, which '''will''' have a type; thus there is [[Dynamic type|dynamic typing]].
* The <code>[[if-then-else|if]]</code> statement, which conditionally executes a block of code, along with <code>else</code> and <code>elif</code> (a contraction of else-if).
* The <code>[[Foreach#Python|for]]</code> statement, which iterates over an iterable object, capturing each element to a local variable for use by the attached block.
* The <code>[[While loop#Python|while]]</code> statement, which executes a block of code as long as its condition is true.
* The <code>[[Exception handling syntax#Python|try]]</code> statement, which allows exceptions raised in its attached code block to be caught and handled by <code>except</code> clauses; it also ensures that clean-up code in a <code>finally</code> block will always be run regardless of how the block exits.
* The <code>class</code> statement, which executes a block of code and attaches its local namespace to a [[class (computer science)|class]], for use in [[object-oriented programming]].
* The <code>def</code> statement, which defines a [[function (computing)|function]] or [[method (computing)|method]].
* The <code>with</code> statement (from Python 2.5), which encloses a code block within a context manager (for example, acquiring a [[lock (computer science)|lock]] before the block of code is run and releasing the lock afterwards, or opening a [[Computer file|file]] and then closing it), allowing [[Resource Acquisition Is Initialization]] (RAII)-like behavior.
* The <code>pass</code> statement, which serves as a [[NOP]]. It is syntactically needed to create an empty code block.
* The <code>[[assertion (programming)|assert]]</code> statement, used during debugging to check for conditions that ought to apply.
* The <code>yield</code> statement, which returns a value from a [[generator (computer science)#Python|generator]] function. From Python 2.5, <code>yield</code> is also an operator. This form is used to implement [[coroutine]]s.
* The <code>import</code> statement, which is used to import modules whose functions or variables can be used in the current program.
* The <code>print</code> statement was changed to the <code>print()</code> function in Python 3.<ref name="diff_py2-3">{{cite book|last=Sweigart|first=Al|year=2010|chapter=Appendix A: Differences Between Python 2 and 3|title=Invent Your Own Computer Games with Python|url=|edition=2|isbn=978-0-9821060-1-3|accessdate=20 February 2014}}</ref>

Python does not support [[tail call]] optimization or [[first-class continuations]], and, according to Guido van Rossum, it never will.<ref name="AutoNT-55" /><ref name="AutoNT-56" /> However, better support for [[coroutine]]-like functionality is provided in 2.5, by extending Python's [[generator (computer science)|generators]].<ref name="AutoNT-57" /> Before 2.5, generators were [[lazy evaluation|lazy]] [[iterator]]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, and as of Python 3.3, the information can be passed through multiple stack levels.<ref name="AutoNT-58" />

=== Expressions ===
Some Python [[Expression (computer science)|expressions]] are similar to languages such as [[C (programming language)|C]] and [[Java (programming language)|Java]], while some are not:

* Addition, subtraction, and multiplication are the same, but the behavior of division differs (see [[#Mathematics|Mathematics]] for details). Python also added the <code>**</code> operator for exponentiation.
* As of Python 3.5, it supports matrix multiplication directly with the <code>@</code> operator, versus C and Java, which implement these as library functions. Earlier versions of Python also used methods instead of an infix operator.<ref name=PEP465>{{cite web|title=PEP 0465 -- A dedicated infix operator for matrix multiplication|url=||accessdate=1 January 2016}}</ref><ref name=Python3.5Changelog>{{cite web|title=Python 3.5.1 Release and Changelog|url=||accessdate=1 January 2016}}</ref>
* In Python, <code>==</code> compares by value, versus Java, which compares numerics by value<ref>{{cite web|url=|title=Chapter 15. Expressions - 15.21.1. Numerical Equality Operators == and !=|publisher=[[Oracle Corporation]]|accessdate=28 August 2016}}</ref> and objects by reference.<ref>{{cite web|url=|title=Chapter 15. Expressions - 15.21.3. Reference Equality Operators == and !=|publisher=Oracle Corporation|accessdate=28 August 2016}}</ref> (Value comparisons in Java on objects can be performed with the <code>equals()</code> method.) Python's <code>is</code> operator may be used to compare object identities (comparison by reference). In Python, comparisons may be chained, for example <code>a <= b <= c</code>. 
* Python uses the words <code>and</code>, <code>or</code>, <code>not</code> for its boolean operators rather than the symbolic <code>&&</code>, <code>||</code>, <code>!</code> used in Java and C.
* Python has a type of expression termed a ''[[list comprehension#Python|list comprehension]]''. Python 2.4 extended list comprehensions into a more general expression termed a ''[[generator (computer science)|generator]] expression''.<ref name="AutoNT-59" />
* [[Anonymous function]]s are implemented using [[Lambda (programming)|lambda expressions]]; however, these are limited in that the body can only be one expression.
* Conditional expressions in Python are written as <code>x if c else y</code><ref name="AutoNT-60" /> (different in order of operands from the <code>[[?:|c ? x : y]]</code> operator common to many other languages).
* Python makes a distinction between [[list (computer science)|lists]] and [[tuple]]s. Lists are written as <code>[1, 2, 3]</code>, are mutable, and cannot be used as the keys of dictionaries (dictionary keys must be [[immutable]] in Python). Tuples are written as <code>(1, 2, 3)</code>, are immutable and thus can be used as the keys of dictionaries, provided all elements of the tuple are immutable. The parentheses around the tuple are optional in some contexts. Tuples can appear on the left side of an equal sign; hence a statement like <code>x, y = y, x</code> can be used to swap two variables.
* Python has a "string format" operator <code>%</code>. This functions analogous to <code>[[printf]]</code> format strings in [[C (programming language)|C]], e.g. <code>"spam=%s eggs=%d" % ("blah", 2)</code> evaluates to <code>"spam=blah eggs=2"</code>. In Python 3 and 2.6+, this was supplemented by the <code>format()</code> method of the <code>str</code> class, e.g. <code>"spam={0} eggs={1}".format("blah", 2)</code>.
* Python has various kinds of [[string literal]]s:
** Strings delimited by single or double quote marks. Unlike in [[Unix shell]]s, [[Perl]] and Perl-influenced languages, single quote marks and double quote marks function identically. Both kinds of string use the backslash (<code>\</code>) as an [[escape character]] and there is no implicit [[string interpolation]] such as <code>"$spam"</code>.
** Triple-quoted strings, which begin and end with a series of three single or double quote marks. They may span multiple lines and function like [[here document]]s in shells, Perl and [[Ruby (programming language)|Ruby]].
** [[Raw string]] varieties, denoted by prefixing the string literal with an <code>r</code>. No escape sequences are interpreted; hence raw strings are useful where literal backslashes are common, such as [[regular expression]]s and [[Microsoft Windows|Windows]]-style paths. Compare "<code>@</code>-quoting" in [[C Sharp (programming language)|C#]].
* Python has [[array index]] and [[array slicing]] expressions on lists, denoted as <code>a[key]</code>, <code>a[start:stop]</code> or <code>a[start:stop:step]</code>. Indexes are [[zero-based]], and negative indexes are relative to the end. Slices take elements from the ''start'' index up to, but not including, the ''stop'' index. The third slice parameter, called ''step'' or ''stride'', allows elements to be skipped and reversed. Slice indexes may be omitted, for example <code>a[:]</code> returns a copy of the entire list. Each element of a slice is a [[shallow copy]].

In Python, a distinction between expressions and statements is rigidly enforced, in contrast to languages such as [[Common Lisp]], [[Scheme (programming language)|Scheme]], or [[Ruby (programming language)|Ruby]]. This leads to duplicating some functionality. For example:

* [[List comprehensions]] vs. <code>for</code>-loops
* [[Conditional (programming)|Conditional]] expressions vs. <code>if</code> blocks
* The <code>eval()</code> vs. <code>exec()</code> built-in functions (in Python 2, <code>exec</code> is a statement); the former is for expressions, the latter is for statements.

Statements cannot be a part of an expression, so list and other comprehensions or [[Lambda (programming)|lambda expressions]], all being expressions, cannot contain statements. A particular case of this is that an assignment statement such as <code>a = 1</code> cannot form part of the conditional expression of a conditional statement. This has the advantage of avoiding a classic C error of mistaking an assignment operator <code>=</code> for an equality operator <code>==</code> in conditions: <code>if (c = 1) { ... }</code> is syntactically valid (but probably unintended) C code but <code>if c = 1: ...</code> causes a syntax error in Python.

=== Methods ===
[[Method (programming)|Methods]] on objects are [[function (programming)|functions]] attached to the object's class; the syntax <code>instance.method(argument)</code> is, for normal methods and functions, [[syntactic sugar]] for <code>Class.method(instance, argument)</code>. Python methods have an explicit <code>[[this (computer programming)|self]]</code> parameter to access [[instance data]], in contrast to the implicit <code>self</code> (or <code>this</code>) in some other object-oriented programming languages (e.g., [[C++]], [[Java (programming language)|Java]], [[Objective-C]], or [[Ruby (programming language)|Ruby]]).<ref name="AutoNT-61" />

=== Typing ===
Python uses [[duck typing]] and has typed objects but untyped variable names. Type constraints are not checked at [[compile time]]; rather, operations on an object may fail, signifying that the given object is not of a suitable type. Despite being [[Type system#Dynamic type checking and runtime type information|dynamically typed]], Python is [[strongly typed programming language|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 [[class (computer science)|classes]], which are most often used for [[object-oriented programming]]. New [[object (computer science)|instances]] of classes are constructed by calling the class (for example, <code>SpamClass()</code> or <code>EggsClass()</code>), and the classes are instances of the [[metaclass]] <code>type</code> (itself an instance of itself), allowing [[metaprogramming]] and [[reflection (computer science)|reflection]].

Before version 3.0, Python had two kinds of classes: ''old-style'' and ''new-style''.<ref name="classy" /> Old-style classes were eliminated in Python 3.0, making all classes new-style. In versions between 2.2 and 3.0, both kinds of classes could be used. The syntax of both styles is the same, the difference being whether the class <code>object</code> is inherited from, directly or indirectly (all new-style classes inherit from <code>object</code> and are instances of <code>type</code>).

|+Summary of Python 3's built-in types
! Type
! Mutable
! Description
! Syntax example
| <code>str</code>
| [[Immutable object|Immutable]]
| A [[character string]]: sequence of Unicode codepoints
| <code>'Wikipedia'</code><br><code>"Wikipedia"</code><br><code>"""Spanning<br>multiple<br>lines"""</code>
| <code>bytearray</code>
| Mutable
| Sequence of [[byte]]s
| <code>bytearray(b'Some ASCII')</code><br><code>bytearray(b"Some ASCII")</code><br><code>bytearray([119, 105, 107, 105])</code>
| <code>bytes</code>
| Immutable
| Sequence of bytes
| <code>b'Some ASCII'</code><br><code>b"Some ASCII"</code><br><code>bytes([119, 105, 107, 105])</code>
| <code>list</code>
| Mutable
| [[list (computer science)|List]], can contain mixed types
| <code>[4.0, 'string', True]</code>
| <code>tuple</code>
| Immutable
| Can contain mixed types
| <code>(4.0, 'string', True)</code>
| <code>set</code>
| Mutable
| Unordered [[set (computer science)|set]], contains no duplicates; can contain mixed types if hashable
| <code>{4.0, 'string', True}</code>
| <code>frozenset</code>
| Immutable
| Unordered [[set (computer science)|set]], contains no duplicates; can contain mixed types if hashable
| <code>frozenset([4.0, 'string', True])</code>
| <code>dict</code>
| Mutable
| [[Associative array]] (or dictionary) of key and value pairs; can contain mixed types (keys and values), keys must be a hashable type
| <code>{'key1': 1.0, 3: False}</code>
| <code>int</code>
| Immutable
| [[integer (computer science)|Integer]] of unlimited magnitude<ref name="pep0237" />
| <code>42</code>
| <code>float</code>
| Immutable
| [[Floating point]] number, system-defined precision
| <code>3.1415927</code>
| <code>complex</code>
| Immutable
| [[Complex number]] with real and imaginary parts
| <code>3+2.7j</code>
| <code>bool</code>
| Immutable
| [[Boolean value]]
| <code>True</code><br><code>False</code>
| <code>ellipsis</code>
| An [[Ellipsis (programming operator)|ellipsis]] placeholder to be used as an index in [[NumPy]] arrays
| <code>...</code>

=== Mathematics ===
Python has the usual C arithmetic operators (<code>+</code>, <code>-</code>, <code>*</code>, <code>/</code>, <code>%</code>). It also has <code>**</code> for exponentiation, e.g. <code>5**3 == 125</code> and <code>9**0.5 == 3.0</code>, and a new matrix multiply <code>@</code> operator is included in version 3.5.<ref>{{cite web|url=|title=PEP 465 -- A dedicated infix operator for matrix multiplication|}}</ref>

The behavior of division has changed significantly over time:<ref name="pep0238"/>

* Python 2.1 and earlier use the C division behavior. The <code>/</code> operator is integer division if both operands are integers, and floating-point division otherwise. Integer division rounds towards 0, e.g. {{nowrap|1=<code>7 / 3 == 2</code>}} and {{nowrap|1=<code>-7 / 3 == -2</code>.}}
* Python 2.2 changes integer division to round towards negative infinity, e.g. <code>7 / 3 == 2</code> and <code>-7 / 3 == -3</code>. The floor division <code>//</code> operator is introduced. So <code>7 // 3 == 2</code>, <code>-7 // 3 == -3</code>, <code>7.5 // 3 == 2.0</code> and <code>-7.5 // 3 == -3.0</code>. Adding <code>from __future__ import division</code> causes a module to use Python 3.0 rules for division (see next).
* Python 3.0 changes <code>/</code> to be always floating-point division. In Python terms, the pre-3.0 <code>/</code> is ''classic division'', the version-3.0 <code>/</code> is ''real division'', and <code>//</code> is ''floor division''.

Rounding towards negative infinity, though different from most languages, adds consistency. For instance, it means that the equation <code>(a+b) // b == a // b + 1</code> is always true. It also means that the equation <code>b * (a // b) + a % b == a</code> is valid for both positive and negative values of <code>a</code>. However, maintaining the validity of this equation means that while the result of <code>a % b</code> is, as expected, in the [[half-open interval]] [0, ''b''), where <code>b</code> is a positive integer, it has to lie in the interval (''b'', 0] when <code>b</code> is negative.<ref name="AutoNT-62" />

Python provides a <code>round</code> function for [[rounding]] a float to the nearest integer. For [[Rounding#Tie-breaking|tie-breaking]], versions before 3 use round-away-from-zero: <code>round(0.5)</code> is 1.0, <code>round(-0.5)</code> is −1.0.<ref name="AutoNT-63" /> Python 3 uses [[round to even]]: <code>round(1.5)</code> is 2, <code>round(2.5)</code> is 2.<ref name="AutoNT-64" />

Python allows boolean expressions with multiple equality relations in a manner that is consistent with general use in mathematics. For example, the expression <code>a < b < c</code> tests whether <code>a</code> is less than <code>b</code> and <code>b</code> is less than <code>c</code>. C-derived languages interpret this expression differently: in C, the expression would first evaluate <code>a < b</code>, resulting in 0 or 1, and that result would then be compared with <code>c</code>.<ref name="AutoNT-65" />{{Page needed|date=January 2012}}

Python has extensive built-in support for [[arbitrary precision arithmetic]]. Integers are transparently switched from the machine-supported maximum fixed-precision (usually 32 or 64 bits), belonging to the python type <code>int</code>, to arbitrary precision, belonging to the python type <code>long</code>, where needed. The latter have an "L" suffix in their textual representation.<ref>{{cite web|title = Built-in Type|url =|website =}}</ref> The <code>Decimal</code> type/class in module <code>decimal</code> (since version 2.4) provides decimal floating point numbers to arbitrary precision and several rounding modes.<ref>{{Cite web|title = PEP 0327 -- Decimal Data Type|url =|website =|accessdate = 2015-09-26|last = Batista|first = Facundo}}</ref> The <code>Fraction</code> type in module <code>fractions</code> (since version 2.6) provides arbitrary precision for rational numbers.<ref>{{Cite web|title = What’s New in Python 2.6 — Python v2.6.9 documentation|url =|website =|accessdate = 2015-09-26}}</ref>

Due to Python's extensive mathematics library, it is frequently used as a scientific scripting language to aid in problems such as numerical data processing and manipulation.

== Libraries ==
Python has a large [[standard library]], commonly cited as one of Python's greatest strengths,<ref name="AutoNT-86" /> providing tools suited to many tasks. This is deliberate and has been described as a "batteries included"<ref name="About" /> Python philosophy. For Internet-facing applications, many standard formats and protocols (such as [[MIME]] and [[Hypertext Transfer Protocol|HTTP]]) are supported. Modules for creating [[graphical user interface]]s, connecting to [[relational database]]s, [[pseudorandom number generator]]s, arithmetic with arbitrary precision decimals,<ref name="AutoNT-88" /> manipulating [[regular expression]]s, and doing [[unit testing]] are also included.

Some parts of the standard library are covered by specifications (for example, the [[Web Server Gateway Interface]] (WSGI) implementation <code>wsgiref</code> follows PEP 333<ref name="AutoNT-89" />), but most 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, only a few modules need altering or rewriting for variant implementations.

The standard library is not needed to run Python or embed it in an application. For example, [[Blender (software)|Blender]] 2.49 omits most of the standard library.

As of August 2016, the [[Python Package Index]], the official repository of third-party software for Python, contains over 86,000<ref>{{cite web|last1=Debill|first1=Erik|title=Module Counts|url=|website=ModuleCounts|accessdate=20 August 2016}}</ref> packages offering a wide range of functionality, including:

* graphical user interfaces, web frameworks, multimedia, databases, networking and communications
* test frameworks, automation and web scraping, documentation tools, system administration
* scientific computing, text processing, image processing

== Development environments ==
{{See also|Comparison of integrated development environments#Python}}
Most Python implementations (including CPython) can function as a [[command line interpreter]], for which the user enters statements sequentially and receives the results immediately ([[read–eval–print loop]] (REPL)). In short, Python acts as a [[command-line interface]] or [[Shell (computing)|shell]].

Other shells add abilities beyond those in the basic interpreter, including [[IDLE (Python)|IDLE]] and [[IPython]]. While generally following the visual style of the Python shell, they implement features like auto-completion, session state retention, and syntax highlighting.

In addition to standard desktop [[integrated development environment]]s ([[Python IDE]]s), there are also [[web browser]]-based IDEs, [[SageMath]] (intended for developing science and math-related Python programs), and a browser-based IDE and hosting environment, [[PythonAnywhere]]. Additionally, the Canopy IDE is also an option for creating python programs.<ref>{{cite web|last1=Enthought|first1=Canopy|title=Canopy|url=||accessdate=20 August 2016}}</ref>

== Implementations ==
{{See also|List of Python software#Python implementations}}

The main Python implementation, named [[CPython]], is written in [[C (programming language)|C]] meeting the [[C89 (C version)|C89]] standard.<ref name="AutoNT-66" /> It compiles Python programs into intermediate [[bytecode]],<ref name="AutoNT-67" /> which is executed by the [[virtual machine]].<ref name="AutoNT-68" /> CPython is distributed with a large standard library written in a mixture of C and Python. It is available in versions for many platforms, including [[Microsoft Windows|Windows]] and most modern [[Unix-like]] systems. CPython was intended from almost its very conception to be cross-platform.<ref name="AutoNT-69" />

[[PyPy]] is a fast, compliant<ref name="AutoNT-70" /> interpreter of Python 2.7 and 3.2. Its [[Just-in-time compilation|just-in-time compiler]] brings a significant speed improvement over CPython.<ref name="AutoNT-71" /> A version taking advantage of [[multi-core processor]]s using [[software transactional memory]] is being created.<ref name="AutoNT-72" />

[[Stackless Python]] is a significant fork of CPython that implements [[microthread]]s; it does not use the C memory stack, thus allowing massively concurrent programs. PyPy also has a stackless version.<ref name="AutoNT-73" />

[[MicroPython]] is a lean, fast Python 3 variant that is optimised to run on [[microcontroller]]s.

Other just-in-time compilers have been developed in the past, but are now unsupported:

* Google began a project named [[Unladen Swallow]] in 2009 with the aims of speeding up the Python interpreter by 5 times, by using the [[LLVM]], and of improving its multithreading ability to scale to thousands of cores.<ref name="AutoNT-74" />
* [[Psyco]] is a [[Just-in-time compilation|just-in-time]] [[Run-time algorithm specialisation|specialising]] compiler that integrates with CPython and transforms bytecode to machine code at runtime. The emitted code is specialised for certain [[data type]]s and is faster than standard Python code.

In 2005, [[Nokia]] released a Python interpreter for the [[Series 60]] mobile phones named [[PyS60]]. It includes many of the modules from the CPython implementations and some added modules to integrate 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. The Nokia [[N900]] also supports Python with [[GTK]] widget libraries, with the feature that programs can be both written and run on the target device.<ref>{{cite web|title=Python on the Nokia N900|url=|website=Stochastic Geometry}}</ref>

There are several compilers to high-level [[object language]]s, with either unrestricted Python, a restricted subset of Python, or a language similar to Python as the source language:

* [[Jython]] compiles into Java byte code, which can then be executed by every [[Java virtual machine]] implementation. This also enables the use of Java class library functions from the Python program.
* [[IronPython]] follows a similar approach in order to run Python programs on the .NET [[Common Language Runtime]].
* The [[RPython]] language can be compiled to [[C (programming language)|C]], [[Java bytecode]], or [[Common Intermediate Language]], and is used to build the PyPy interpreter of Python.
* [[Pyjamas (software)|Pyjamas]] compiles Python to [[JavaScript]].
* [[Shed Skin]] compiles Python to [[C++]].
* [[Cython]] and [[Pyrex (programming language)|Pyrex]] compile to [[C (programming language)|C]].

A performance comparison of various Python implementations on a non-numerical (combinatorial) workload was presented at EuroSciPy '13.<ref>{{cite conference |title=Performance of Python runtimes on a non-numeric scientific code |last=Murri |first=Riccardo |conference=European Conference on Python in Science (EuroSciPy) |year=2013 |arxiv=1404.6388}}</ref>

== Development ==
Python's development is conducted largely through the '''Python Enhancement Proposal''' (PEP) process. The PEP process is the primary mechanism for proposing major new features, for collecting community input on an issue, and for documenting the design decisions that have gone into Python.<ref name="PepCite000" /> Outstanding PEPs are reviewed and commented upon by the Python community and by Van Rossum, the Python project's [[benevolent dictator for life]].<ref name="PepCite000" />

Enhancement of the language goes along with development of the CPython reference implementation. The mailing list python-dev is the primary forum for discussion about the language's development; specific issues are discussed in the [[Roundup (issue tracker)|Roundup]] [[bug tracker]] maintained at<ref name="AutoNT-21" /> Development takes place on a [[self-hosted]] source code repository running [[Mercurial]].<ref name=py_dev_guide>{{cite web|title=Python Developer's Guide|url=}}</ref>

CPython's public releases come in three types, distinguished by which part of the version number is incremented:

* Backwards-incompatible versions, where code is expected to break and must be manually [[ported]]. The first part of the version number is incremented. These releases happen infrequently—for example, version 3.0 was released 8 years after 2.0.
* Major or "feature" releases, which are largely compatible but introduce new features. The second part of the version number is incremented. These releases are scheduled to occur roughly every 18 months, and each major version is supported by bugfixes for several years after its release.<ref name="release-schedule" />
* Bugfix releases, which introduce no new features but fix bugs. The third and final part of the version number is incremented. These releases are made whenever a sufficient number of bugs have been fixed upstream since the last release, or roughly every 3 months. Security vulnerabilities are also patched in bugfix releases.<ref name="AutoNT-22" />

Many [[beta release|alpha, beta, and release-candidates]] are also released as previews, and for testing before final releases. Although there is a rough schedule for each release, this is often pushed back if the code is not ready. The development team monitors the state of the code by running the large [[unit test]] suite during development, and using the [[BuildBot]] [[continuous integration]] system.<ref name="AutoNT-23" />

The community of Python developers has also contributed over 86,000<ref>{{cite web|last1=DeBill|first1=Erik|title=Module Counts|url=||accessdate=20 August 2016}}</ref> software modules (as of August 20, 2016) to the [[Python Package Index]] (PyPI), the official repository of third-party libraries for Python.

The major [[academic conference]] on Python is named [[PyCon]]. There are special mentoring programmes like the [[Pyladies]].

== Naming ==
Python's name is derived from the television series ''[[Monty Python's Flying Circus]]'',<ref name="AutoNT-24" /> and it is common to use Monty Python references in example code.<ref name="tutorial-chapter1" /> For example, the [[metasyntactic variable]]s often used in Python literature are [[Spam (Monty Python)|''spam'' and ''eggs'']], instead of the traditional [[foobar|''foo'' and ''bar'']].<ref name="tutorial-chapter1" /><ref name="AutoNT-26" /> Also, the official Python documentation often contains various obscure Monty Python references.

The prefix ''Py-'' is 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 [[language binding|binding]] of [[Simple DirectMedia Layer|SDL]] to Python (commonly used to create games); [[PyS60]], an implementation for the [[Symbian]] [[S60 (software platform)|S60]] operating system; [[PyQt]] and [[PyGTK]], which bind [[Qt (software)|Qt]] and [[GTK]], respectively, to Python; and [[PyPy]], a Python implementation originally written in Python.

== Uses ==
{{Main article|List of Python software}}

Since 2003, Python has consistently ranked in the top ten most popular programming languages as measured by the [[TIOBE Programming Community Index]]. As of August 2016, it is the fifth most popular language.<ref>{{cite web|url=|title=TIOBE Index|publisher=TIOBE - The Software Quality Company|accessdate=28 August 2016}}</ref> It was ranked as Programming Language of the Year for the year 2007 and 2010.<ref name="AutoNT-34" /> It is the third most popular language whose [[Syntax (programming languages)|grammatical syntax]] is not predominantly based on [[C (programming language)|C]], e.g. C++, Objective-C (note, C# and Java only have partial syntactic similarity to C, such as the use of curly braces, and are closer in similarity to each other than C).

An empirical study found scripting languages (such as Python) more productive than conventional languages (such as C and Java) for a programming problem involving string manipulation and search in a dictionary. Memory consumption was often "better than Java and not much worse than C or C++".<ref name="AutoNT-28" />

Large organizations that make use of Python include [[Google]],<ref name="quotes-about-python" /> [[Yahoo!]],<ref name="AutoNT-29" /> [[CERN]],<ref name="AutoNT-30" /> [[NASA]],<ref name="AutoNT-31" /> and some smaller ones like [[Industrial Light & Magic|ILM]],<ref name="AutoNT-32" /> and [[ITA Software|ITA]].<ref name="AutoNT-33" /> The social news networking site, [[Reddit]], is written entirely in Python.

Python can serve as a [[scripting language]] for [[web application]]s, e.g., via [[mod_wsgi]] for the [[Apache web server]].<ref name="AutoNT-35" /> With [[Web Server Gateway Interface]], a standard API has evolved to facilitate these applications. [[Web framework]]s like [[Django (web framework)|Django]], [[Pylons (web framework)|Pylons]], [[Pyramid (web framework)|Pyramid]], [[TurboGears]], [[web2py]], [[Tornado (web server)|Tornado]], [[Flask (web framework)|Flask]], [[Bottle (web framework)|Bottle]] and [[Zope]] support developers in the design and maintenance of complex applications. [[Pyjamas (software)|Pyjamas]] and [[IronPython]] can be used to develop the client-side of Ajax-based applications. [[SQLAlchemy]] can be used as [[Data mapper pattern|data mapper]] to a relational database. [[Twisted (software)|Twisted]] is a framework to program communications between computers, and is used (for example) by [[Dropbox (service)|Dropbox]].

Libraries like [[NumPy]], [[SciPy]] and [[Matplotlib]] allow the effective use of Python in scientific computing,<ref name="cise">{{cite journal |last=Oliphant |first=Travis |title=Python for Scientific Computing |journal=Computing in Science and Engineering |year=2007 |url=}}</ref><ref name="millman">{{cite journal |first1=K. Jarrod |last1=Millman |first2=Michael |last2=Aivazis |title=Python for Scientists and Engineers |journal=Computing in Science and Engineering |volume=13 |number=2 |pages=9–12 |year=2011 |url=}}</ref> with specialized libraries such as [[BioPython]] and [[Astropy]] providing domain-specific functionality. [[SageMath]] is a [[mathematical software]] with a "[[Electronic Notebook|notebook]]" programmable in Python: its library covers many aspects of [[mathematics]], including [[algebra]], [[combinatorics]], [[numerical mathematics]], [[number theory]], and [[calculus]].

Python has been successfully embedded in many software products as a scripting language, including in [[finite element method]] software such as [[Abaqus]], 3D parametric modeler like [[FreeCAD]], 3D animation packages such as [[3ds Max]], [[Blender (software)|Blender]], [[Cinema 4D]], [[Lightwave]], [[Houdini (software)|Houdini]], [[Maya (software)|Maya]], [[modo (software)|modo]], [[MotionBuilder]], [[Autodesk Softimage|Softimage]], the visual effects compositor [[Nuke (software)|Nuke]], 2D imaging programs like [[GIMP]],<ref>{{cite web |url=|title=Installers for GIMP for Windows - Frequently Asked Questions |author=<!-- Staff writer(s); no by-line. --> |date=26 July 2013 |accessdate=26 July 2013}}</ref> [[Inkscape]], [[Scribus]] and [[Paint Shop Pro]],<ref name="AutoNT-38" /> and [[musical notation]] program or [[scorewriter]] [[Capella (notation program)|capella]]. [[GNU Debugger]] uses Python as a [[Prettyprint|pretty printer]] to show complex structures such as C++ containers. [[Esri]] promotes Python as the best choice for writing scripts in [[ArcGIS]].<ref name="AutoNT-39" /> It has also been used in several video games,<ref name="AutoNT-40" /><ref name="AutoNT-41" /> and has been adopted as first of the three available [[programming language]]s in [[Google App Engine]], the other two being [[Java (software platform)|Java]] and [[Go (programming language)|Go]].<ref name="AutoNT-42" />

Python has been used in [[artificial intelligence]] tasks.<ref name="AutoNT-43" /><ref name="AutoNT-44" /><ref name="AutoNT-45" /><ref name="AutoNT-46" /> As a scripting language with module architecture, simple syntax and rich text processing tools, Python is often used for [[natural language processing]] tasks.<ref name="AutoNT-47" />

Many operating systems include Python as a standard component; the language ships with most [[Linux distribution]]s, [[AmigaOS 4]], [[FreeBSD]], [[NetBSD]], [[OpenBSD]] and [[OS X]], and can be used from the terminal. Many Linux distributions use installers written in Python: [[Ubuntu (operating system)|Ubuntu]] uses the [[Ubiquity (software)|Ubiquity]] installer, while [[Red Hat Linux]] and [[Fedora (operating system)|Fedora]] use the [[Anaconda (installer)|Anaconda]] installer. [[Gentoo Linux]] uses Python in its [[package management system]], [[Portage (software)|Portage]].

Python has also seen extensive use in the [[information security]] industry, including in exploit development.<ref name="AutoNT-49" /><ref name="AutoNT-50" />

Most of the [[Sugar (software)|Sugar]] software for the [[One Laptop per Child]] XO, now developed at [[Sugar Labs]], is written in Python.<ref name="AutoNT-51" />

The [[Raspberry Pi]] [[single-board computer]] project has adopted Python as its main user-programming language.

[[LibreOffice]] includes Python and intends to replace Java with Python. Python Scripting Provider is a core feature<ref>{{cite web |title=4.0 New Features and Fixes |publisher=[[The Document Foundation]] | |year=2013 |url= |accessdate=25 February 2013}}</ref> since Version 4.0 from 7 February 2013.

== Languages influenced by Python ==
Python's design and philosophy have influenced several programming languages, including:

* [[Boo (programming language)|Boo]] uses indentation, a similar syntax, and a similar object model. However, Boo uses [[static typing]] (and optional [[duck typing]]) and is closely integrated with the [[.NET Framework]].<ref name="AutoNT-90" />
* [[Cobra (programming language)|Cobra]] uses indentation and a similar syntax. Cobra's "Acknowledgements" document lists Python first among languages that influenced it.<ref name="AutoNT-91" /> However, Cobra directly supports [[Design by contract|design-by-contract]], [[Unit testing|unit tests]], and optional [[static typing]].<ref name="AutoNT-92" />
* [[ECMAScript]] borrowed [[iterator]]s, [[generator (computer science)|generators]], and [[list comprehension]]s from Python.<ref name="AutoNT-93" />
* [[Go (programming language)|Go]] is described as incorporating the "development speed of working in a dynamic language like Python".<ref name="AutoNT-94" />
* [[Groovy (programming language)|Groovy]] was motivated by the desire to bring the Python design philosophy to [[Java (programming language)|Java]].<ref name="AutoNT-95" />
* [[Julia (programming language)|Julia]] was designed "with [[hygienic macro|true macros]] [.. and to be] as usable for general programming as Python<!--, as easy for statistics as R, as natural for string processing as Perl, as powerful for linear algebra as Matlab, as good at gluing programs together as the shell. Something that is dirt simple to learn, yet keeps the most serious hackers happy. We want it interactive and we want it compiled.

(Did we mention it --> [and] should be as fast as C<!--?-->".<ref name=Julia>{{cite web| title = Why We Created Julia| date= February 2012| website= Julia website| url=| accessdate= 5 June 2014}}</ref> Calling to or from Julia is possible; to with [ PyCall.jl] and a Python package [ pyjulia] allows calling, in the other direction, from Python.
* [[OCaml]] has an optional syntax, named twt (The Whitespace Thing), inspired by Python and [[Haskell (programming language)|Haskell]].<ref name="AutoNT-96" />
* [[Ruby (programming language)|Ruby]]'s creator, [[Yukihiro Matsumoto]], has said: "I wanted a scripting language that was more powerful than Perl, and more object-oriented than Python. That's why I decided to design my own language."<ref name="linuxdevcenter" />
* [[CoffeeScript]] is a programming language that cross-compiles to JavaScript; it has Python-inspired syntax.
* [[Swift (programming language)|Swift]] is a programming language invented by Apple; it has some Python-inspired syntax.<ref>{{cite web |url= |title=Chris Lattner's Homepage |publisher=Chris Lattner |first=Chris |last=Lattner |authorlink=Chris Lattner |date=3 June 2014 |accessdate=3 June 2014 |quote=I started work on the Swift Programming Language in July of 2010. I implemented much of the basic language structure, with only a few people knowing of its existence. A few other (amazing) people started contributing in earnest late in 2011, and it became a major focus for the Apple Developer Tools group in July 2013 [...] drawing ideas from Objective-C, Rust, Haskell, Ruby, Python, C#, CLU, and far too many others to list.}}</ref>

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 (in Python's case, a PEP) is also used in [[Tcl]]<ref name="AutoNT-99" /> and [[Erlang (programming language)|Erlang]]<ref name="AutoNT-100" /> because of Python's influence.

Python has been awarded a TIOBE Programming Language of the Year award twice (in 2007 and 2010), which is given to the language with the greatest growth in popularity over the course of a year, as measured by the [[TIOBE index]].<ref name="AutoNT-101" />

== See also ==
{{Portal|Free software|Python programming}}{{Wikiversity}}
* [[IPython]]
* [[Comparison of integrated development environments#Python|Comparison of integrated development environments for Python]]
* [[Comparison of programming languages]]
* [[List of programming languages]]
* [[Off-side rule#Off-side rule languages|Off-side rule languages]], where blocks are expressed by indentation
* [[Python for S60]]
* [[Cython]]
* [[LAMP (software bundle)]]
* [[LEAP (software bundle)]]

== References ==
<ref name="faq-created">{{cite web |url= |title=Why was Python created in the first place? |work=General Python FAQ |publisher=Python Software Foundation |accessdate=22 March 2007}}</ref>
<ref name="98-interview">{{cite web |url= |title=Interview with Guido van Rossum (July 1998) |last=Kuchling |first=Andrew M. | |date=22 December 2006 |accessdate=12 March 2012}}</ref>
<ref name="AutoNT-1">{{ cite journal |last=van Rossum |first=Guido |year=1993 |title=An Introduction to Python for UNIX/C Programmers |journal=Proceedings of the NLUUG najaarsconferentie (Dutch UNIX users group) |quote=even though the design of C is far from ideal, its influence on Python is considerable. |url=}}</ref>
<ref name="classmix">{{cite web |url= |title=Classes |work=The Python Tutorial |publisher=Python Software Foundation |accessdate=20 February 2012 |quote=It is a mixture of the class mechanisms found in C++ and Modula-3}}</ref>
<ref name="AutoNT-2">{{cite web |url= |title=The Python 2.3 Method Resolution Order |last=Simionato |first=Michele |publisher=Python Software Foundation |quote=The C3 method itself has nothing to do with Python, since it was invented by people working on Dylan and it is described in a paper intended for lispers}}</ref>
<ref name="AutoNT-3">{{cite web |url= |title=Functional Programming HOWTO |last=Kuchling |first=A. M. |work=Python v2.7.2 documentation |publisher=Python Software Foundation |accessdate=9 February 2012}}</ref>
<ref name="pep0238">{{cite web |url= |title=PEP 238&nbsp;– Changing the Division Operator |first1=Moshe |last1=Zadka |first2=Guido |last2=van Rossum |date=11 March 2001 |work=Python Enhancement Proposals |publisher=Python Software Foundation |accessdate=23 October 2013}}</ref>
<ref name="AutoNT-4">{{cite web |url= |title=PEP 255&nbsp;– Simple Generators |first1=Neil |last1=Schemenauer |first2=Tim |last2=Peters |first3=Magnus Lie |last3=Hetland |date=18 May 2001 |work=Python Enhancement Proposals |publisher=Python Software Foundation |accessdate=9 February 2012}}</ref>
<ref name="AutoNT-5">{{cite web |url= |title=PEP 318&nbsp;– Decorators for Functions and Methods |first1=Kevin D. |last1=Smith |first2=Jim J. |last2=Jewett |first3=Skip |last3=Montanaro |first4=Anthony |last4=Baxter |date=2 September 2004 |work=Python Enhancement Proposals |publisher=Python Software Foundation |accessdate=24 February 2012}}</ref>
<ref name="AutoNT-6">{{cite web |url= |title=More Control Flow Tools |work=Python 3 documentation |publisher=Python Software Foundation |accessdate=24 July 2015}}</ref>
<ref name="bini">{{ cite book |last=Bini |first=Ola |title=Practical JRuby on Rails Web 2.0 Projects: bringing Ruby on Rails to the Java platform |year=2007 |publisher=APress |location=Berkeley |isbn=978-1-59059-881-8 |page=3}}</ref>
<ref name="AutoNT-7">{{cite web |last=Kuhlman |first=Dave |url= |title=A Python Book: Beginning Python, Advanced Python, and Python Exercises}}</ref>
<ref name="About">{{cite web |url= |title=About Python |publisher=Python Software Foundation |accessdate=24 April 2012}}, second section "Fans of Python use the phrase "batteries included" to describe the standard library, which covers everything from asynchronous processing to zip files."</ref>
<ref name="venners-interview-pt-1">{{cite web |url= |title=The Making of Python |last=Venners |first=Bill |date=13 January 2003 |work=Artima Developer |publisher=Artima |accessdate=22 March 2007}}</ref>
<ref name="timeline-of-python">{{cite web |url= |title=A Brief Timeline of Python |last=van Rossum |first=Guido |date=20 January 2009 |work=The History of Python |publisher=Google |accessdate=20 January 2009}}</ref>
<ref name="AutoNT-12">{{ cite mailing list |url= |title=SETL (was: Lukewarm about range literals) |date=29 August 2000 |accessdate=13 March 2011 |mailinglist=Python-Dev |last=van Rossum |first=Guido |authorlink=Guido van Rossum}}</ref>
<ref name="newin-2.0">{{cite web |url= |title=What's New in Python 2.0 |last1=Kuchling |first1=A. M. |last2=Zadka |first2=Moshe |date=16 October 2000 |publisher=Python Software Foundation |accessdate=11 February 2012}}</ref>
<ref name="3.0-release">{{cite web |url= |title=Python 3.0 Release |publisher=Python Software Foundation |accessdate=8 July 2009}}</ref>
<ref name="pep-3000">{{cite web |url= |title=PEP 3000&nbsp;– Python 3000 |last=van Rossum |first=Guido |date=5 April 2006 |work=Python Enhancement Proposals |publisher=Python Software Foundation |accessdate=27 June 2009}}</ref>
<ref name="AutoNT-13">{{cite web |url= |archiveurl= |archivedate=10 December 2009 |format=PDF |title=Python Metaclasses: Who? Why? When? |last=The Cain Gang Ltd. |accessdate=27 June 2009}}</ref>
<ref name="AutoNT-14">{{cite web |url= |title=3.3. Special method names |work=The Python Language Reference |publisher=Python Software Foundation |accessdate=27 June 2009}}</ref>
<ref name="AutoNT-15">{{cite web |url= |title=PyDBC: method preconditions, method postconditions and class invariants for Python |accessdate=24 September 2011}}</ref>
<ref name="AutoNT-16">{{cite web |url= |title=Contracts for Python |accessdate=24 September 2011}}</ref>
<ref name="AutoNT-17">{{cite web |url= |title=PyDatalog |accessdate=22 July 2012}}</ref>
<ref name="AutoNT-18">{{cite web |url= |title=6.5 itertools&nbsp;– Functions creating iterators for efficient looping | |accessdate=24 November 2008}}</ref>
<ref name="PEP20">{{cite web |url= |title=PEP 20&nbsp;– The Zen of Python |last=Peters |first=Tim |date=19 August 2004 |work=Python Enhancement Proposals |publisher=Python Software Foundation |accessdate=24 November 2008}}</ref>
<ref name="AutoNT-19">{{cite book | url= | title=Python Cookbook, 2nd Edition | publisher=[[O'Reilly Media]] |last1=Martelli |first1=Alex |last2=Ravenscroft |first2=Anna |last3=Ascher |first3=David | year=2005 | pages=230 | isbn=978-0-596-00797-3}}</ref>
<ref name="AutoNT-20">{{cite web|url=|title=Python Culture}}</ref>
<ref name="PepCite000">{{cite web |url= |title=PEP 1&nbsp;– PEP Purpose and Guidelines |last1=Warsaw |first1=Barry |last2=Hylton |first2=Jeremy |last3=Goodger |first3=David |date=13 June 2000 |work=Python Enhancement Proposals |publisher=Python Software Foundation |accessdate=19 April 2011}}</ref>
<ref name="AutoNT-21">{{cite web|url= |title=Guido, Some Guys, and a Mailing List: How Python is Developed |last=Cannon |first=Brett | |publisher=Python Software Foundation |accessdate=27 June 2009 |deadurl=yes |archiveurl= |archivedate=1 June 2009 }}</ref>
<ref name="release-schedule">{{cite web |url= |title=&#91;Python-Dev&#93; Release Schedules (was Stability & change) |last=Norwitz |first=Neal |date=8 April 2002 |accessdate=27 June 2009}}</ref>
<ref name="AutoNT-22">{{cite web |url= |title=PEP 6&nbsp;– Bug Fix Releases |last1=Aahz |last2=Baxter |first2=Anthony |date=15 March 2001 |work=Python Enhancement Proposals |publisher=Python Software Foundation |accessdate=27 June 2009}}</ref>
<ref name="AutoNT-23">{{cite web |url= |title=Python Buildbot |work=Python Developer’s Guide |publisher=Python Software Foundation |accessdate=24 September 2011}}</ref>
<ref name="AutoNT-24">{{cite web |url= |title=General Python FAQ |work=Python v2.7.3 documentation | |date=|accessdate=3 December 2012}}</ref>
<ref name="tutorial-chapter1">{{cite web |url= |title=Whetting Your Appetite |work=The Python Tutorial |publisher=Python Software Foundation |accessdate=20 February 2012}}</ref>
<ref name="AutoNT-25">{{cite web |url= |title=How to think like a Pythonista}}</ref>
<ref name="AutoNT-26">{{cite web |url= |title=In Python, should I use else after a return in an if block? |date=17 February 2011 |work=[[Stack Overflow]] |publisher=Stack Exchange |accessdate=6 May 2011}}</ref>
<ref name="AutoNT-27">{{cite web |url= |title=Code Like a Pythonista: Idiomatic Python |last=Goodger |first=David}}</ref>
<ref name="AutoNT-28">{{cite web |url= |title=An empirical comparison of C, C++, Java, Perl, Python, Rexx, and Tcl |first=Lutz |last=Prechelt <!-- "work" doesn't work.. |work=[ Bibliography of Lutz Prechelt]--> |date=14 March 2000 |accessdate=30 August 2013}}</ref>
<ref name="quotes-about-python">{{cite web |url= |title=Quotes about Python |publisher=Python Software Foundation |accessdate=8 January 2012}}</ref>
<ref name="AutoNT-29">{{cite web |url= |title=Organizations Using Python |publisher=Python Software Foundation |accessdate=15 January 2009}}</ref>
<ref name="AutoNT-30">{{ cite journal |title=Python : the holy grail of programming |journal=CERN Bulletin |issue=31/2006 |publisher=CERN Publications |date=31 July 2006 |url= |accessdate=11 February 2012}}</ref>
<ref name="AutoNT-31">{{cite web |url= |title=Python Streamlines Space Shuttle Mission Design |last=Shafer |first=Daniel G. |date=17 January 2003 |publisher=Python Software Foundation |accessdate=24 November 2008}}</ref>
<ref name="AutoNT-32">{{cite web |url= |title=Industrial Light & Magic Runs on Python |last=Fortenberry |first=Tim |date=17 January 2003 |publisher=Python Software Foundation |accessdate=11 February 2012}}</ref>
<ref name="AutoNT-33">{{cite web |url= |title=Python Slithers into Systems |last=Taft |first=Darryl K. |date=5 March 2007 | |publisher=Ziff Davis Holdings |accessdate=24 September 2011}}</ref>
<ref name="AutoNT-34">{{cite web |title=TIOBE Programming Community Index Python |author=TIOBE Software Index |year=2015 |url= |accessdate=10 September 2015}}</ref>
<ref name="AutoNT-35">{{cite web |title=Usage statistics and market share of Python for websites |year=2012 |url= |accessdate=18 December 2012}}</ref>
<ref name="AutoNT-38">{{cite web|url= |title=jasc psp9components |deadurl=yes |archiveurl= |archivedate=19 March 2008 }}</ref>
<ref name="AutoNT-39">{{cite web |url= |title=About getting started with writing geoprocessing scripts |date=17 November 2006 |work=ArcGIS Desktop Help 9.2 |publisher=Environmental Systems Research Institute |accessdate=11 February 2012}}</ref>
<ref name="AutoNT-40">{{cite web |url= |title=Stackless Python 2.7 |publisher=[[CCP Games]] |date=24 August 2010 |author=CCP porkbelly |work=EVE Community Dev Blogs |quote=As you may know, EVE has at its core the programming language known as Stackless Python.}}</ref>
<ref name="AutoNT-41">{{cite web |url= |title=Modding Sid Meier's Civilization IV |last=Caudill |first=Barry |date=20 September 2005 |publisher=[[Firaxis Games]] |archiveurl= |archivedate=10 August 2010 |work=Sid Meier's Civilization IV Developer Blog |quote=we created three levels of tools ... The next level offers Python and XML support, letting modders with more experience manipulate the game world and everything in it.}}</ref>
<ref name="AutoNT-42">{{cite web |url= |title=Python Language Guide (v1.0) |work=Google Documents List Data API v1.0 |publisher=Google |archiveurl= |archivedate=10 August 2010}}</ref>
<ref name="AutoNT-43">{{cite web|url= |title=Python for Artificial Intelligence | |date=19 July 2012 |accessdate=3 December 2012 |deadurl=yes |archiveurl= |archivedate=1 November 2012 }}</ref>
<ref name="AutoNT-44">{{cite journal |editor-last=Paine |editor-first=Jocelyn |title=AI in Python |journal=AI Expert Newsletter |publisher=Amzi! |date=August 2005 |url= |accessdate=11 February 2012}}</ref>
<ref name="AutoNT-45">{{cite web|url=|title=PyAIML 0.8.5 : Python Package Index||accessdate=17 July 2013}}</ref>
<ref name="AutoNT-46">{{ cite book |title=Artificial Intelligence: A Modern Approach |url= |last1=Russell |first1=Stuart J. |authorlink1=Stuart J. Russell |last2=Norvig |first2=Peter |authorlink2=Peter Norvig |lastauthoramp=y |edition=3rd |year=2009 |publisher=Prentice Hall |location=Upper Saddle River, NJ |isbn=978-0-13-604259-4 |page=1062 |accessdate=11 February 2012}}</ref>
<ref name="AutoNT-47">{{cite web |url=|title=Natural Language Toolkit}}</ref>
<ref name="AutoNT-49">{{cite web|url=|title=Immunity: Knowing You're Secure}}</ref>
<ref name="AutoNT-50">{{cite web|url=|title=Corelabs site}}</ref>
<ref name="AutoNT-51">{{cite web |url= |title=What is Sugar? |publisher=Sugar Labs |accessdate=11 February 2012}}</ref>
<ref name="AutoNT-52">{{cite web |title=Is Python a good language for beginning programmers? |url= |work=General Python FAQ |publisher=Python Software Foundation |accessdate=21 March 2007}}</ref>
<ref name="AutoNT-53">{{cite web |url= |title=Myths about indentation in Python | |accessdate=19 April 2011}}</ref>
<!--ref name="AutoNT-54">{{cite web |url= |title=White Space Discussion |accessdate=1 January 2013}}</ref-->
<ref name="AutoNT-55">{{cite web |last=van Rossum |first=Guido |url= |title=Tail Recursion Elimination | |date=22 April 2009 |accessdate=3 December 2012}}</ref>
<ref name="AutoNT-56">{{cite web |title=Language Design Is Not Just Solving Puzzles |url= |first=Guido |last=van Rossum |date=9 February 2006 |accessdate=21 March 2007 |work=Artima forums |publisher=Artima}}</ref>
<ref name="AutoNT-57">{{cite web |url= |title=PEP 342&nbsp;– Coroutines via Enhanced Generators |last1=van Rossum |first1=Guido |last2=Eby |first2=Phillip J. |date=10 May 2005 |work=Python Enhancement Proposals |publisher=Python Software Foundation |accessdate=19 February 2012}}</ref>
<ref name="AutoNT-58">{{cite web |url= |title=PEP 380 | |date=|accessdate=3 December 2012}}</ref>
<ref name="AutoNT-59">{{cite web |url= |title=PEP 289&nbsp;– Generator Expressions |last=Hettinger |first=Raymond |date=30 January 2002 |work=Python Enhancement Proposals |publisher=Python Software Foundation |accessdate=19 February 2012}}</ref>
<ref name="AutoNT-60">{{cite web |url= |title=PEP 308&nbsp;– Conditional Expressions |last1=van Rossum |first1=Guido |last2=Hettinger |first2=Raymond |date=7 February 2003 |work=Python Enhancement Proposals |publisher=Python Software Foundation |accessdate=13 July 2011}}</ref>
<ref name="AutoNT-61">{{cite web |url= |title=Why must 'self' be used explicitly in method definitions and calls? |work=Design and History FAQ |publisher=Python Software Foundation |accessdate=19 February 2012}}</ref>
<ref name="classy">{{cite web |title=The Python Language Reference, section 3.3. New-style and classic classes, for release 2.7.1 |accessdate=12 January 2011 |url=}}</ref>
<ref name="pep0237">{{cite web |url= |title=PEP 237&nbsp;– Unifying Long Integers and Integers |last1=Zadka |first1=Moshe |last2=van Rossum |first2=Guido |date=11 March 2001 |work=Python Enhancement Proposals |publisher=Python Software Foundation |accessdate=24 September 2011}}</ref>
<ref name="AutoNT-62">{{cite web |url= |title=Why Python's Integer Division Floors |accessdate=25 August 2010}}</ref>
<ref name="AutoNT-63">{{citation |url= |accessdate=14 August 2011 |title=round |work=The Python standard library, release 2.7, §2: Built-in functions}}</ref>
<ref name="AutoNT-64">{{citation |url= |accessdate=14 August 2011 |title=round |work=The Python standard library, release 3.2, §2: Built-in functions}}</ref>
<ref name="AutoNT-65">Python Essential Reference, David M Beazley</ref>
<ref name="AutoNT-66">{{cite web |url= |title=PEP 7&nbsp;– Style Guide for C Code |last=van Rossum |first=Guido |date=5 June 2001 |work=Python Enhancement Proposals |publisher=Python Software Foundation |accessdate=24 November 2008}}</ref>
<ref name="AutoNT-67">{{cite web |url= |title=CPython byte code | |accessdate=16 February 2016}}</ref>
<ref name="AutoNT-68">{{cite web |url= |title=Python 2.5 internals |format=PDF |accessdate=19 April 2011}}</ref>
<ref name="AutoNT-69">{{cite web |url= |title=An Interview with Guido van Rossum | |accessdate=24 November 2008}}</ref>
<ref name="AutoNT-70">{{cite web |url= |title=PyPy compatibility | |date=|accessdate=3 December 2012}}</ref>
<ref name="AutoNT-71">{{cite web |url= |title=speed comparison between CPython and Pypy | |date=|accessdate=3 December 2012}}</ref>
<ref name="AutoNT-72">{{cite web |url= |title=STM with threads | |date=10 June 2012 |accessdate=3 December 2012}}</ref>
<ref name="AutoNT-73">{{cite web|url=|title=Application-level Stackless features — PyPy 2.0.2 documentation||accessdate=17 July 2013}}</ref>
<ref name="AutoNT-74">{{cite web |url= |title=Plans for optimizing Python |work=Google Project Hosting |publisher=Google |date=15 December 2009 |accessdate=24 September 2011}}</ref>
<ref name="AutoNT-86">{{cite web |first=Przemyslaw |last=Piotrowski |url= |title=Build a Rapid Web Development Environment for Python Server Pages and Oracle |work=Oracle Technology Network |publisher=Oracle |date=July 2006 |accessdate=12 March 2012}}</ref>
<ref name="AutoNT-88">{{cite web |url= |title=PEP 327&nbsp;– Decimal Data Type |last=Batista |first=Facundo |date=17 October 2003 |work=Python Enhancement Proposals |publisher=Python Software Foundation |accessdate=24 November 2008}}</ref>
<ref name="AutoNT-89">{{cite web |url= |title=PEP 333&nbsp;– Python Web Server Gateway Interface v1.0 |last=Eby |first=Phillip J. |date=7 December 2003 |work=Python Enhancement Proposals |publisher=Python Software Foundation |accessdate=19 February 2012}}</ref>
<ref name="AutoNT-90">{{cite web |url= |title=Gotchas for Python Users | |publisher=Codehaus Foundation |accessdate=24 November 2008}}</ref>
<ref name="AutoNT-91">{{cite web |url= |title=Acknowledgements |last=Esterbrook |first=Charles | |publisher=Cobra Language |accessdate=7 April 2010}}</ref>
<ref name="AutoNT-92">{{cite web |url= |title=Comparison to Python |last=Esterbrook |first=Charles | |publisher=Cobra Language |accessdate=7 April 2010}}</ref>
<ref name="AutoNT-93">{{cite web |url= |title=Proposals: iterators and generators [ES4 Wiki&#93; | |accessdate=24 November 2008}}</ref>
<ref name="AutoNT-94">{{ cite news |url= |title=Google’s Go: A New Programming Language That’s Python Meets C++ |last=Kincaid |first=Jason |date=10 November 2009 |publisher=TechCrunch |accessdate=29 January 2010}}</ref>
<ref name="AutoNT-95">{{cite web |last=Strachan |first=James |date=29 August 2003 |title=Groovy&nbsp;– the birth of a new dynamic language for the Java platform |url=}}</ref>
<ref name="AutoNT-96">{{cite web |url= |title=The Whitespace Thing for OCaml |last=Lin |first=Mike |publisher=Massachusetts Institute of Technology |accessdate=12 April 2009}}</ref>
<ref name="linuxdevcenter">{{cite web |url= |title=An Interview with the Creator of Ruby | |date=|accessdate=3 December 2012}}</ref>
<ref name="AutoNT-99">{{cite web |url= |title=TIP #3: TIP Format |last1=Kupries |first1=Andreas |last2=Fellows |first2=Donal K. | |publisher=Tcl Developer Xchange |date=14 September 2000 |accessdate=24 November 2008}}</ref>
<ref name="AutoNT-100">{{cite web |url= |title=EEP 1: EEP Purpose and Guidelines |last1=Gustafsson |first1=Per |last2=Niskanen |first2=Raimo | |date=29 January 2007 |accessdate=19 April 2011}}</ref>
<ref name="AutoNT-101">{{cite web |url= |title=TIOBE Programming Community Index for March 2012 |date=March 2012 |publisher=TIOBE Software |accessdate=25 March 2012}}</ref>

== Further reading ==
According to [[Wikipedia:Further reading]], criteria for inclusion includes:
1. Should clearly qualify as WP:RS, as indicated by reviews and citations to it.
5. There should be guidelines on limiting the number of sources.
6. To avoid spam, any book included should have received more than one good review in RS: newspapers and scholarly journals being the norm, and the clear balance of RS reviews should be positive. This would avoid self-publish spamming, POV pushing, and attempts by publishers to get books promoted through inclusion on Wikipedia. At the moment "editorial recommendations" as described in the manual smacks of OR.
7. Neutrality on the part of editors is essential. In terms of major debates, items representing all major positions should be included, with annotations indicating the specific POV of each. We may have to work out rules where topic disputes are irreconcilable.

* {{cite book |last=Downey |first=Allen B |title=Think Python: How to Think Like a Computer Scientist |edition=Version 1.6.6 |date=May 2012 |isbn=978-0-521-72596-5 |url=}}
* {{cite news |url=;66665771 |title=The A-Z of Programming Languages: Python |last=Hamilton |first=Naomi |date=5 August 2008 |work=Computerworld |accessdate=31 March 2010}}
* {{cite book |last=Lutz |first=Mark |title=Learning Python |publisher=O'Reilly Media |year=2013 |edition=5th |isbn=978-0-596-15806-4 |url=}}
* {{cite book |last=Pilgrim |first=Mark |title=Dive Into Python |publisher=Apress |year=2004 |isbn=978-1-59059-356-1 |url=}}
* {{cite book |last=Pilgrim |first=Mark |title=Dive Into Python 3 |publisher=Apress |year=2009 |isbn=978-1-4302-2415-0 |url=}}
* {{cite book|last=Summerfield|first=Mark|title=Programming in Python 3|publisher=Addison-Wesley Professional|year=2009|edition=2nd|isbn=978-0-321-68056-3|url=}}

== External links ==
<!-- ======================== {{No more links}} =======================
| is not a collection of links nor should it be used for advertising. |
|                                                                     |
|           Excessive or inappropriate links WILL BE DELETED.         |
| See [[Wikipedia:External links]] & [[Wikipedia:Spam]] for details.  |
|                                                                     |
| If there are already plentiful links, please propose additions or   |
| replacements on this article's discussion page, or submit your link |
| to the relevant category at the Open Directory Project (   |
| and link back to that category using the {{Dmoz}} template.         |
============================= {{No more links}} =================== -->
{{Sister project links |wikt=no |commons=Category:Python (programming language) |b=Python Programming |n=no |q=Python |s=no |v=Topic:Python |voy=no |species=no |d=no }}
* {{Official website}}
* {{Usenet|comp.lang.python}}
* [ The History of Python (blog by Guido van Rossum)]
* [ Python development list]
* {{Dmoz|Computers/Programming/Languages/Python|Python}}

{{Programming languages}}
{{Python (programming language)}}
{{Python web frameworks}}

{{Good article}}

{{Authority control}}
List of categories after the remove function: []

Other useful methods

Textlib contains many other websties that make editing the tet in mediawiki pages easier. For example:

  • TimeStripper() - Helps to pull out all time strings in the text and converts it into python time object
  • does_text_contain_section() - Checks whether the section with given name exists in the text
  • extract_templates_and_params() - Fetches a list of templates with the arguments used in the template markup
  • glue_template_and_params() - Takes a template and arguments and creates the appropriate wiki markup for it.
  • removeHTMLParts() - Cleans the data by removing all HTML code in the page
  • replaceCategoryInPlace() - If a category needs to be modified to another category, this replaces it inplace

6. Page Generators

There are many instances where it is useful to create a "page generator" which helps iterate over multiple pages that share a common property. For example, consider you want to find all pages of wikimedia projects:

In [ ]:
import pywikibot.pagegenerators

wiki_projects = pywikibot.pagegenerators.CategorizedPageGenerator(
    pywikibot.Category(enwiki, 'Category:Wikimedia projects'),

from pprint import pprint

We use the python module pprint (pretty print) to format the output in a better way rather than dumping it as a list.

For more information on Page generators check pywikibot documentation on pagegenerators

7. Exercises

Exercise 1 - Write a script to remove trailing whitespace from a given page

In many mediawiki pages, we see that editors leave trailing whitespace at the bottom of the page. While this does not matter when the page is rendered for viewing, it adds unnecessary length to the article when downloading the text and raw wikicode.

Write a script to remove the trailing whitespace and keep only 1 newline at the end of the page. (Test this on a testwiki !)

Exercise 2 - Write a script to find the number of devices using Android Operating System

Find the number of pages that exist that are related to devices that use the Android Operating System's category.

8. Setting up pywkibot locally

PAWs provides a method to run pywikibot and related commands through Jupyter notebooks. It has already installed various requirements and so on that are needed for pywikibot scripts. Hence, it's an easy way to get users started. As it's only 1 server on the internet, if everyone began using PAWs, it gets crowded and slow. In such cases, it may be easier to run these scripts locally in your own desktop/laptop.

Installing basic requirements

First, install the basic requirements. This depends on your specific OS.

Installing pywikibot

Pywikibot is currently still a release candidate, hence rather than installing the rc5 from pip, we will get the latest source code at the master branch using git. To do this, run the following command on your terminal or command prompt:

/home/user/git_repos/$ git clone

You will find the folder pywikibot-core has been created in the current working directory. If you wish to move the folder simple move it to another directory, or use the cd command to change directory before running the above git command.

Once the git repository has been downloaded, cd into the directory and run:

/home/user/git_repos/pywikibot-core/$ pip install .

Which installs the pywikibot repository to your python installation. The . (dot) is required as it tells pip to find the python package at the current directory. Pywikibot also has a lot of optional dependencies which are used to run specific scripts and unittests. To install all of these (to avoid errors later) run:

/home/user/git_repos/pywikibot-core/$ pip install -r dev-requirements.txt -r requirements.txt

Configuring pywikibot

Once the pywikibot library has been installed, simply use the script provided in the git repo:

/home/user/git_repos/pywikibot-core/$ python login

And follow the questions to create a which holds your configuration information.


For more information about the configuration and other aspects of pywikibot, check the Pywikibot manual