First page Back Continue Last page Overview Graphics

First-class Everything

Guido van Rossum designed the language under the slogan "first-class everything". He wrote: "One of my goals for Python was to make it so that all objects were "first class." By this, I meant that I wanted all objects that could be named in the language (e.g., integers, strings, functions, classes, modules, methods, etc.) to have equal status. That is, they can be assigned to variables, placed in lists, stored in dictionaries, passed as arguments, and so forth."

(Blog, The History of Python, February 27, 2009)

>>> x = 42

>>> type(x)

<class 'int'>

>>> y = 4.34

>>> type(x)

<class 'int'>

>>> def f(x):

... return x + 1

...

>>> type(f)

<class 'function'>

>>> import math

>>> type(math)

<class 'module'>