The Python language defines a number of special names that have particular significance. These usually begin and end with two underscores, for example: __add__.

Due to technical limitations, it is not possible to create a well-named page for each of these names; attempting to name a page "__add__", for example, will end up creating a page that is just named "add". Consequently, some of these names are collected here, and others are placed on pages dealing with various interfaces (such as a list of names to be defined to make a class instance behave like a numeric type).

This page is a work in progress and many more names of this type remain to be documented.

Special names in the global namespaceEdit


A module can define the name __all__ as a sequence type containing one or more strings. The strings name objects in the module's namespace that will be the only ones visible from outside the module. All of the objects so named must exist.


The module __builtin__ contains all of the built-in functions. It does not have to be imported.


The module __future__ contains functionality that is soon to present in later Python releases. It was added in 2.3.

For example, to use the with statement in 2.5:

 from __future__ import with_statement


The main module of a Python program, the one that contains the original script launched by some other program and imports all the others, gets the name of __main__, regardless of the name of the file. This allows a module to contain test code that will run if the module is run as a program, but not if it is imported:

if __name__ == "__main__":
    # Test code goes here


The global variable __name__ contains an eight-bit string giving the name of the current module.

Special names that are members or methods of class instancesEdit

Every class instance has these special names as members or methods, whether or not they have been explicitly created.


__dict__ is a dictionary object with eight-bit strings as keys and all of the members and methods as values. That is, spam.__dict__["eggs"] is equivalent to spam.eggs. __dict__ can be used, for example, to test for the existence of a member: the expression "eggs" in spam.__dict__ is true if and only if spam has a member or method named eggs.

Community content is available under CC-BY-SA unless otherwise noted.