Built-in Modules

Built-in modules are always available but must be imported to be used in client modules. To access them, use one of these formats:

  • import module, and qualify module names (module.name)

  • from module import name, and use module names unqualified (name)

  • from module import *, and use module names unqualified (name)

For instance, to use name argv in the sys module, either use import sys and name sys.argv, or use from sys import argv and name argv.

There are hundreds of built-in modules; the next sections document the more commonly used ones. Listed export names followed by parentheses are functions that must be called; others are simple attributes (i.e., variable names in modules).

Get Python Pocket Reference, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.