Questions tagged
Python is a multi-paradigm, dynamically typed, multipurpose programming language. It is designed to be quick to learn, understand, and use, and enforces a clean and uniform syntax. Please note that Python 2 is officially out of support as of 01-01-2020. Still, for version-specific Python questions, add the [python-2.7] or [python-3.x] tag. When using a Python variant (e.g., Jython, PyPy) or library (e.g., Pandas and NumPy), please include it in the tags.

Python is an interpreted, interactive, object-oriented (using classes), dynamic and strongly typed programming language that is used for a wide range of applications. It incorporates modules, exceptions, dynamic typing, very high-level dynamic data types, and classes. Python combines remarkable power with very clear syntax. It has interfaces to many system calls and libraries, as well as to various window systems, and is extensible in c or c++. It is also usable as an extension language for applications that need a programmable interface. Finally, Python is portable: it runs on many Unix variants, on the Mac, and on Windows 2000 and later.

The language comes with a large standard library that covers areas such as string processing (regular expressions, Unicode, calculating differences between files), Internet protocols (HTTP, FTP, SMTP, XML-RPC, POP, IMAP, and CGI programming), software engineering (unit testing, logging, profiling, and parsing Python code), and operating system interfaces (system calls, filesystems, and TCP/IP sockets). Look at the table of contents for The Python Standard Library to get an idea of what’s available. A wide variety of third-party extensions are also available. Consult the Python Package Index to find packages of interest to you.

Python allows programmers to express concepts in fewer lines of code than would be possible in many other languages, such as C, and the language has constructs intended to be used to create clear programs in a variety of domains.


Python program

print("Hello, Stack Overflow!")


C program

#include <stdio.h>
int main(void) {
    printf("Hello, Stack Overflow!");
    return 0;

Python was originally created by Guido van Rossum and first released in 1991. Guido Van Rossum 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 (16 October 2000 - 01 January 2020) has officially been sunset, and Python 3 (3 December 2008) is the only supported, maintained and improved major version as of 01 January 2020. We have a community of people from both worlds, and if you have a question that relates to a specific version, please consider mentioning the version and implementation that you are using, when asking a question about Python (see Tagging Recommendation section below).

Python supports multiple programming paradigms, including object-oriented, imperative, and functional programming styles. It features a fully dynamic type system and automatic memory management, similar to that of Scheme, Ruby, Perl, and Tcl.

Like other dynamic languages, Python is often used as a scripting language but is also used in a wide range of non-scripting contexts. Using third-party tools, Python code can be packaged into standalone executable programs. Python interpreters are available for many operating systems.

CPython, the reference implementation of Python, is free and open-source software. It has a community-based development model, as do nearly all of its alternative implementations. There are a wide variety of implementations more suited for specific environments or tasks (see Python implementations on the Python wiki).

The philosophy of Python is succinctly formulated in The Zen of Python, written by Tim Peters, which one can read by issuing this command, in the interactive python interpreter:

>>> import this

Unlike many other languages, Python uses an indentation-based syntax (in which tabs and spaces are noninterchangeable). This may take some getting used to for programmers who are familiar with using braces.

>>> from __future__ import braces
  File "<stdin>", line 1
SyntaxError: not a chance

To help with the transition, using a properly configured text-editor or IDE is recommended. Python comes with a basic IDE called IDLE (python-idle), to get you started. Other popular examples are the charityware Vim, the free GNU Emacs, Eclipse+PyDev, or PyCharm. Take a look at this IDE comparison list for many other alternatives.

There is also a style guide for Python, named PEP 8, which aims to make Python code more readable and consistent. This guide is (should be) followed all across the Python development community.

Tagging Recommendation:

Use the python tag, for all Python-related questions. If you believe your question includes issues specific to individual versions, use python-3.x or python-2.7, in addition to the main python tag. If you believe your question maybe even more specific, you can include a version-specific tag such as python-3.5 or python-3.6, etc.

Also, consider including the tag for the specific implementation (jython, pypy, etc.), if you are using one other than cpython — the use of cpython is assumed unless explicitly stated otherwise.


These are some of the common questions many beginners face and can serve as canonical duplicate targets:

User input:

Value testing:

Common errors:

Dealing with lists:

Dealing with dicts:



Installation of External Packages:

  • Pip pip

    Most of the Python libraries used for simple and advanced scripts are downloaded using pip , the Python Package Installer.It allows you to install and manage additional packages that are not part of the Python standard library.Most distributions of Python come with pip pre-installed. General syntax:

$ pip install SomePackage
Successfully installed SomePackage
  • easy_install easy-install

    easy_install was released in 2004, as part of setuptools. It was notable at the time for installing packages from PyPI using requirement specifiers, and automatically installing dependencies. Easy Install is deprecated. Do not use it. Instead use pip.

Popular general use Python libraries:

  • Requests requests

    A simple Python library for making HTTP requests. Requests are marketed as being "For Humans". The library is meant to simplify and universalize Python's many methods for making HTTP requests in a way that is readable and easy to use. Functionality such as keep-alive and connection pooling are automatically handled to provide ultimate simplicity.

  • Pillow python-imaging-library

    Pillow is described as being a "friendly fork" of the Python PIL module, an unmaintained but useful imaging library. The library uses C APIs to provide an easy Python interface to modify and manipulate image files in many different ways.

  • Scrapy scrapy

    Scrapy is a fast high-level web crawling and web scraping framework used to crawl websites and extract structured data from their pages. It can be used for a wide range of purposes, from data mining to monitoring and automated testing.

  • Beautiful Soup beautifulsoup bs4

    Beautiful Soup is a Python package for parsing HTML and XML documents. It creates a parse tree for parsed pages that can be used to extract data from HTML, which is useful for web scraping. It is available for Python 2.7 and Python 3.

  • nltk nltk

    The Natural Language Toolkit, or NLTK, is a platform for building Python applications to work with human language data and the processing of sentences. It provides easy-to-use interfaces to over 50 corpora and lexical resources such as WordNet, along with a suite of text processing libraries for classification, tokenization, stemming, tagging, parsing, and semantic reasoning, and providing wrappers for industrial-strength NLP libraries.

Popular web frameworks based on Python:

If your question has anything to do with any of these frameworks, please ensure you include the appropriate tag.

  • Django django

    The Web framework for perfectionists (with deadlines). Django makes it easier to build better Web apps more quickly and with less code. Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. It lets you build high-performance, elegant Web applications quickly. Django focuses on automating as much as possible and adhering to the DRY (Don't Repeat Yourself) principle.

  • Flask flask

    Flask is a lightweight micro-framework and third party library for Python based on Werkzeug, Jinja 2 and good intentions. It provides monolithic structure and does not enforce dependencies which allows for finer control and higher freedom for development.

  • Quart quart

    The quart is an evolution of the Flask API to work with Asyncio and to provide a number of features not present or possible in Flask.

  • Tornado tornado

    Tornado is a Python web framework and asynchronous networking library. By using the non-blocking network I/O, Tornado can scale to tens of thousands of open connections, making it ideal for long polling, WebSockets, and other applications that require a long-lived connection to each user.

  • CherryPy cherrypy

    CherryPy is a Pythonic, object-oriented web framework that enables developers to build web applications, in much the same way they would build any other object-oriented Python program. This results in a smaller amount of source code which is developed in less time. CherryPy has been in use for over 17 years and it is being used in production by many sites, from the simplest to the most demanding.

  • Pyramid pyramid

    A lightweight web framework emphasizing flexibility and rapid development. It combines the very best ideas from the worlds of Ruby, Python and Perl, providing a structured but extremely flexible Python web framework. It's also one of the first projects to leverage the emerging WSGI standard, which allows extensive re-use and flexibility, but only if you need it.

  • TurboGears turbogears

    TurboGears is a scalable web framework, which can go from a minimal mode setup to a full-stack web application. It was created in 2005 by Kevin Dangoor, and the current development of TurboGears2 (turbogears2) is being led by Mark Ramm. The current stable release of TurboGears is TurboGears 2.4.1, released September 3rd 2019

  • is a web framework for Python that is as simple as it is powerful. is in the public domain: you can use it for whatever purpose with absolutely no restrictions. lets you write web apps in Python.

  • Grok grok

    Built on the existing Zope 3 libraries but aims to provide an easier learning curve and a more agile development experience. Grok does this by placing an emphasis on convention over configuration and DRY (Don't Repeat Yourself).

  • Bottle bottle

    The bottle is a fast, simple and lightweight WSGI micro web-framework for Python. It is distributed as a single file module and has no dependencies other than the Python Standard Library.

  • web2py web2py

    web2py is a free open source full-stack framework for rapid development of fast, scalable, secure and portable database-driven web-based applications.

  • Falcon falconframework

    Falcon is a minimal Python web framework for building microservices, app backends, and higher-level frameworks and encourages the REST architectural style. It has both community and commercial versions.

  • Twisted twisted

    Twisted is an open-source event-driven networking engine. It is useful for implementing both clients and servers and scales up to large websites and down to embedded devices. Twisted makes it easy to implement custom network applications.

Popular Python GUI Frameworks based on Python

  • Kivy kivy

    Kivy is an OpenGL ES 2 accelerated framework for the creation of new user interfaces. It supports multiple platforms namely Windows, Mac OS X, Linux, Android iOS, and Raspberry Pi. It is open source and comes with over 20 widgets in its toolkit.Additional Material Objects are available via KivyMD.

  • PyQT pyqt

    PyQT is one of the favoured cross-platform Python bindings implementing the Qt library for the Qt (owned by Nokia) application development framework. Currently, PyQT is available for Unix/Linux, Windows, Mac OS X, and Sharp Zaurus. It combines the best of Python and Qt and it up to the programmer to decide whether to create a program by coding or using Qt Designer to create visual dialogs.

    It is available in both commercial as well as GPL license. Although some features may not be available in the free version, if your application is open source, then you can use it under the free license.

    The latest iteration of PyQt is v5

  • Tkinter tkinter

    Tkinter is commonly bundled with Python, using Tk and is Python’s standard GUI framework. It is popular for its simplicity and graphical user interface. It is open-source and available under the Python License. One of the advantages of choosing Tkinter is that since it comes by default, there is an abundance of resources, both codes and reference books. Also with the community being old and active, there are many users who can help you out in case of questions.

  • PyGUI pygui

    PyGUI is a graphical application cross-platform framework for Unix, Macintosh, and Windows. Compared to some other GUI frameworks, PyGUI is by far the simplest and lightweight of them all, as the API is purely in sync with Python. PyGUI inserts very little code between the GUI platform and your Python application, hence the display of the application usually displays the natural GUI of the platform.

Popular Mathematical/Scientific computing libraries in Python

  • NumPy numpy

    NumPy is the fundamental package for scientific computing with Python. It contains among other things:

    • a powerful N-dimensional array object
    • sophisticated (broadcasting) functions
    • tools for integrating C/C++ and Fortran code
    • useful linear algebra, Fourier transform, and random number capabilities

    These features also make it possible to use NumPy in general-purpose database applications.

  • SciPy scipy

    SciPy is an open-source library for the Python programming language, consisting of mathematical algorithms and functions often used in science and engineering. SciPy includes algorithms and tools for tasks such as optimization, clustering, discrete Fourier transforms, linear algebra, signal processing, and multi-dimensional image processing. SciPy is closely related to NumPy and depends on many NumPy functions, including a multidimensional array that is used as the basic data structure in SciPy.

  • matplotlib matplotlib

    matplotlib is a plotting library for the Python programming language and its NumPy numerical mathematics extension. It provides an object-oriented API for embedding plots into applications, using general-purpose GUI toolkits like wxPython, Qt, or GTK. There is also a procedural "pylab" interface, based on a state machine (like OpenGL), designed to closely resemble that of MATLAB.

  • Pandas pandas

    Pandas is an open-source BSD-licensed library providing high-performance, easy to use data structures and data analysis tools for the Python programming language. Pandas integrates many other libraries' features, namely NumPy's matrix operations, and Matplotlib's plotting capabilities. 10 Minutes to Pandas is a good tutorial for first exposure to Pandas.

  • theano theano

    Theano is a Python-C-based widely-used library suitable for highly computational mathematical tasks due to the optimizations it does on the interface Python code making it highly optimized using its C-based routines. It is a very popular library for machine-learning researchers as well. It features a highly optimized automatic differentiation, easing the implementations of highly complicated functions and computing their gradients without any errors.

  • Blender blender

    Blender is a free and open-source 3D animation suite. It supports the entirety of the 3D pipeline—modeling, rigging, animation, simulation, rendering, compositing and motion tracking, even video editing and game creation.

  • scikit-learn scikit-learn

    scikit-learn is a free and open-source machine learning library written in Python. It supports training and testing many different kinds of machine learning models, along with some basic data processing techniques.

  • TensorFlow tensorflow

    TensorFlow is an open-source software library, developed by the Google Brain team. It is a symbolic math library, used mostly for machine learning applications, such as neural networks.

Popular C extension solutions:

With C extension, you can make your python code faster. If your question has anything to do with any of the next solutions, please ensure you include the appropriate tag.

  • ctypes ctypes

    ctypes is a Python package that wraps C .dll/.so libraries in pure Python.

  • SWIG swig

    SWIG is an interface compiler that connects programs written in C and C++ with scripting languages such as Python.

  • Cython cython

    Cython is an optimising static compiler for both the Python programming language and the extended Cython programming language (based on Pyrex). It makes writing C extensions for Python as easy as Python itself.


Chat Rooms

  • Chat at the dedicated IRC channel #python on Freenode for all things Python. Look at Python IRC listing for a specific alternative channel, if interested.

  • Chat about Python with other Stack Overflow users in the Python chat room.

Other Sites

Free Python Programming Books

Interactive Python Learning

  • Codecademy - Learn the fundamentals of Python and dynamic programming
  • CodeSkulptor - Interactive online IDE for Python 2 programming
  • CodeSkulptor 3 - Interactive online IDE for Python 3 programming
  • Coursera - Online course for introduction to interactive Python programming
  • CheckiO - A game world you can explore, using your Python programming skills
  • Dataquest - Interactive Python courses for data science
  • PyCharm Edu - A desktop application that offers interactive Python learning
  • Interactive Python - Includes a modified, interactive version of How to Think Like a Computer Scientist
  • Python Tutor - Visualization and/or live coding in Python
  • Computer Science Circles - Learn basic Python 3 in a semi-interactive fashion.
  • CodingBat (Python) - After learning some basics, refine and hone your Python skills with live coding problems.

Python Online Courses

Python Video Tutorials

Python for Scientists

Python Online IDE

  • ideone - An online IDE, with other popular language support.
  • - Online interpreter for Python 2 and 3 that simplifies saving and sharing code.
  • python shell - Online console from PythonAnywhere.
  • pythonfiddle - Python Cloud IDE.
  • pyfiddle - Python 2.7/3.6 online console.

Code Quality

  • Codacy - Automated Code Review to ship better code, faster.
  • Codecov - Code coverage dashboard.
  • CodeFactor - Automated Code Review for Git.
  • Landscape - Hosted continuous Python code metrics.

Official Logo

Python logo

Active Podcasts

Inactive Podcasts