Core Python functionality available without imports. These are the fundamental building blocks that every Python program can use directly.
Functions for converting between different data types and representations.
def abs(x) -> number:
"""Return the absolute value of a number."""
def bin(x) -> str:
"""Convert an integer to a binary string prefixed with '0b'."""
def bool(x=False) -> bool:
"""Convert a value to a Boolean using standard truth testing."""
def chr(i) -> str:
"""Return Unicode character from integer code point."""
def complex(real=0, imag=0) -> complex:
"""Create a complex number from real and imaginary parts."""
def float(x=0.0) -> float:
"""Convert string or number to floating point number."""
def hex(x) -> str:
"""Convert integer to hexadecimal string prefixed with '0x'."""
def int(x=0, base=10) -> int:
"""Convert string or number to integer."""
def oct(x) -> str:
"""Convert integer to octal string prefixed with '0o'."""
def ord(c) -> int:
"""Return Unicode code point of a one-character string."""
def repr(obj) -> str:
"""Return string representation of object."""
def str(object='', encoding='utf-8', errors='strict') -> str:
"""Convert object to string representation."""Functions for creating and working with container types.
def dict(mapping=None, **kwargs) -> dict:
"""Create a dictionary from mapping or keyword arguments."""
def frozenset(iterable=None) -> frozenset:
"""Create an immutable set from an iterable."""
def list(iterable=None) -> list:
"""Create a list from an iterable."""
def memoryview(obj) -> memoryview:
"""Create memory view object from bytes-like object."""
def range(start, stop=None, step=1) -> range:
"""Create range object for generating sequences."""
def set(iterable=None) -> set:
"""Create a set from an iterable."""
def slice(start, stop=None, step=None) -> slice:
"""Create slice object for sequence indexing."""
def tuple(iterable=None) -> tuple:
"""Create a tuple from an iterable."""
def bytearray(source=None, encoding='utf-8') -> bytearray:
"""Create mutable sequence of bytes."""
def bytes(source=None, encoding='utf-8') -> bytes:
"""Create immutable sequence of bytes."""Functions for working with iterables and sequences.
def all(iterable) -> bool:
"""Return True if all elements are true (or iterable is empty)."""
def any(iterable) -> bool:
"""Return True if any element is true."""
def enumerate(iterable, start=0):
"""Return enumerate object yielding (index, value) pairs."""
def filter(function, iterable):
"""Filter iterable elements for which function returns true."""
def iter(object, sentinel=None):
"""Return iterator object from iterable or callable."""
def len(obj) -> int:
"""Return length of object."""
def map(function, *iterables):
"""Apply function to every item of iterables."""
def max(iterable, key=None, default=None):
"""Return maximum value from iterable."""
def min(iterable, key=None, default=None):
"""Return minimum value from iterable."""
def next(iterator, default=None):
"""Retrieve next item from iterator."""
def reversed(seq):
"""Return reverse iterator over sequence."""
def sorted(iterable, key=None, reverse=False) -> list:
"""Return new sorted list from iterable."""
def sum(iterable, start=0):
"""Sum numeric values in iterable."""
def zip(*iterables):
"""Combine iterables element-wise."""Functions for examining and manipulating object attributes and properties.
def callable(obj) -> bool:
"""Return True if object is callable."""
def dir(obj=None) -> list:
"""Return list of valid attributes for object."""
def getattr(obj, name, default=None):
"""Get named attribute from object."""
def globals() -> dict:
"""Return dictionary of current global namespace."""
def hasattr(obj, name) -> bool:
"""Return True if object has named attribute."""
def hash(obj) -> int:
"""Return hash value of object."""
def id(obj) -> int:
"""Return identity (memory address) of object."""
def isinstance(obj, classinfo) -> bool:
"""Return True if object is instance of class."""
def issubclass(class_, classinfo) -> bool:
"""Return True if class is subclass of classinfo."""
def locals() -> dict:
"""Return dictionary of current local namespace."""
def type(obj) -> type:
"""Return type of object."""
def vars(obj=None) -> dict:
"""Return __dict__ attribute of object."""Functions for interacting with the user and file system.
def input(prompt='') -> str:
"""Read string from standard input."""
def open(file, mode='r', buffering=-1, encoding=None, errors=None,
newline=None, closefd=True, opener=None):
"""Open file and return file object."""
def print(*values, sep=' ', end='\n', file=None, flush=False) -> None:
"""Print values to text stream."""Functions for executing and compiling Python code.
def compile(source, filename, mode, flags=0, dont_inherit=False, optimize=-1):
"""Compile source into code object."""
def eval(expression, globals=None, locals=None):
"""Evaluate expression and return result."""
def exec(object, globals=None, locals=None) -> None:
"""Execute Python code."""
def __import__(name, globals=None, locals=None, fromlist=(), level=0):
"""Import module by name."""Functions for manipulating object attributes and performing operations.
def delattr(obj, name) -> None:
"""Delete named attribute from object."""
def format(value, format_spec='') -> str:
"""Format value according to format specification."""
def pow(base, exp, mod=None):
"""Return base raised to power exp."""
def round(number, ndigits=None):
"""Round number to given precision."""
def setattr(obj, name, value) -> None:
"""Set named attribute of object to value."""Functions for working with classes and methods.
def classmethod(func):
"""Convert function to class method."""
def property(fget=None, fset=None, fdel=None, doc=None):
"""Create property descriptor."""
def staticmethod(func):
"""Convert function to static method."""
def super(type=None, object_or_type=None):
"""Return proxy object for accessing parent class methods."""Functions for development and debugging assistance.
def breakpoint(*args, **kws) -> None:
"""Enter debugger at call site."""
def help(obj=None) -> None:
"""Display help information about object."""Functions for asynchronous iterator support.
def aiter(async_iterable):
"""Return asynchronous iterator from async iterable."""
def anext(async_iterator, default=None):
"""Return next item from async iterator."""None: type[None] # Null value
True: bool # Boolean true
False: bool # Boolean false
Ellipsis: ellipsis # Ellipsis constant (...)
NotImplemented: type[NotImplemented] # Not implemented marker
__debug__: bool # Debug flagclass BaseException:
"""Base class for all exceptions."""
def __init__(self, *args) -> None: ...
def __str__(self) -> str: ...
@property
def args(self) -> tuple: ...
class SystemExit(BaseException):
"""Request to exit from the interpreter."""
def __init__(self, code=None) -> None: ...
@property
def code(self) -> int: ...
class KeyboardInterrupt(BaseException):
"""Program interrupted by user."""
class GeneratorExit(BaseException):
"""Request generator to exit."""class Exception(BaseException):
"""Base class for all built-in non-system-exiting exceptions."""
class ArithmeticError(Exception):
"""Base class for arithmetic errors."""
class LookupError(Exception):
"""Base class for lookup errors."""
class ValueError(Exception):
"""Inappropriate argument value."""
class TypeError(Exception):
"""Inappropriate argument type."""
class NameError(Exception):
"""Name not found globally."""
class AttributeError(Exception):
"""Attribute not found."""
class ImportError(Exception):
"""Import cannot find module or name."""
class ModuleNotFoundError(ImportError):
"""Module cannot be located."""
class OSError(Exception):
"""Operating system error."""
def __init__(self, *args) -> None: ...
@property
def errno(self) -> int: ...
@property
def strerror(self) -> str: ...
@property
def filename(self) -> str: ...
class FileNotFoundError(OSError):
"""File or directory not found."""
class PermissionError(OSError):
"""Permission denied."""
class IndexError(LookupError):
"""Sequence index out of range."""
class KeyError(LookupError):
"""Key not found in mapping."""
class ZeroDivisionError(ArithmeticError):
"""Division by zero."""
class OverflowError(ArithmeticError):
"""Numeric result too large."""
class RuntimeError(Exception):
"""Generic runtime error."""
class NotImplementedError(RuntimeError):
"""Method or function not implemented."""
class SyntaxError(Exception):
"""Invalid syntax."""
def __init__(self, *args) -> None: ...
@property
def filename(self) -> str: ...
@property
def lineno(self) -> int: ...
@property
def text(self) -> str: ...
class IndentationError(SyntaxError):
"""Improper indentation."""
class TabError(IndentationError):
"""Inconsistent use of tabs and spaces."""
class SystemError(Exception):
"""Internal error in the Python interpreter."""
class ReferenceError(Exception):
"""Weak reference proxy used after referent was deleted."""
class MemoryError(Exception):
"""Out of memory."""
class RecursionError(RuntimeError):
"""Maximum recursion depth exceeded."""
class StopIteration(Exception):
"""Iterator is exhausted."""
def __init__(self, value=None) -> None: ...
@property
def value(self): ...
class StopAsyncIteration(Exception):
"""Async iterator is exhausted."""
class AssertionError(Exception):
"""Assert statement failed."""
class EOFError(Exception):
"""Input hits end-of-file condition."""
class FloatingPointError(ArithmeticError):
"""Floating point operation failed."""
class UnicodeError(ValueError):
"""Unicode-related error."""
class UnicodeDecodeError(UnicodeError):
"""Unicode decoding error."""
class UnicodeEncodeError(UnicodeError):
"""Unicode encoding error."""
class UnicodeTranslateError(UnicodeError):
"""Unicode translation error."""class int:
"""Arbitrary precision integer type."""
def __init__(self, x=0, base=10) -> None: ...
def __add__(self, other) -> int: ...
def __sub__(self, other) -> int: ...
def __mul__(self, other) -> int: ...
def __truediv__(self, other) -> float: ...
def __floordiv__(self, other) -> int: ...
def __mod__(self, other) -> int: ...
def __pow__(self, other, modulo=None) -> int: ...
def __and__(self, other) -> int: ...
def __or__(self, other) -> int: ...
def __xor__(self, other) -> int: ...
def __lshift__(self, other) -> int: ...
def __rshift__(self, other) -> int: ...
def __neg__(self) -> int: ...
def __pos__(self) -> int: ...
def __abs__(self) -> int: ...
def __invert__(self) -> int: ...
def bit_length(self) -> int: ...
def to_bytes(self, length, byteorder, signed=False) -> bytes: ...
@classmethod
def from_bytes(cls, bytes, byteorder, signed=False) -> int: ...
class float:
"""Double precision floating point number."""
def __init__(self, x=0.0) -> None: ...
def __add__(self, other) -> float: ...
def __sub__(self, other) -> float: ...
def __mul__(self, other) -> float: ...
def __truediv__(self, other) -> float: ...
def __mod__(self, other) -> float: ...
def __pow__(self, other) -> float: ...
def __neg__(self) -> float: ...
def __pos__(self) -> float: ...
def __abs__(self) -> float: ...
def is_integer(self) -> bool: ...
def hex(self) -> str: ...
@classmethod
def fromhex(cls, s) -> float: ...
class complex:
"""Complex number with real and imaginary parts."""
def __init__(self, real=0, imag=0) -> None: ...
@property
def real(self) -> float: ...
@property
def imag(self) -> float: ...
def conjugate(self) -> complex: ...
def __add__(self, other) -> complex: ...
def __sub__(self, other) -> complex: ...
def __mul__(self, other) -> complex: ...
def __truediv__(self, other) -> complex: ...
def __pow__(self, other) -> complex: ...
def __abs__(self) -> float: ...
class bool(int):
"""Boolean type with True/False values."""
def __init__(self, x=False) -> None: ...class str:
"""Unicode string type."""
def __init__(self, object='', encoding='utf-8', errors='strict') -> None: ...
def __len__(self) -> int: ...
def __getitem__(self, index) -> str: ...
def __add__(self, other) -> str: ...
def __mul__(self, count) -> str: ...
def __contains__(self, sub) -> bool: ...
def upper(self) -> str: ...
def lower(self) -> str: ...
def capitalize(self) -> str: ...
def title(self) -> str: ...
def strip(self, chars=None) -> str: ...
def lstrip(self, chars=None) -> str: ...
def rstrip(self, chars=None) -> str: ...
def split(self, sep=None, maxsplit=-1) -> list: ...
def rsplit(self, sep=None, maxsplit=-1) -> list: ...
def join(self, iterable) -> str: ...
def replace(self, old, new, count=-1) -> str: ...
def find(self, sub, start=0, end=None) -> int: ...
def index(self, sub, start=0, end=None) -> int: ...
def count(self, sub, start=0, end=None) -> int: ...
def startswith(self, prefix, start=0, end=None) -> bool: ...
def endswith(self, suffix, start=0, end=None) -> bool: ...
def isdigit(self) -> bool: ...
def isalpha(self) -> bool: ...
def isalnum(self) -> bool: ...
def isspace(self) -> bool: ...
def format(self, *args, **kwargs) -> str: ...
def encode(self, encoding='utf-8', errors='strict') -> bytes: ...
class list:
"""Mutable sequence type."""
def __init__(self, iterable=None) -> None: ...
def __len__(self) -> int: ...
def __getitem__(self, index): ...
def __setitem__(self, index, value) -> None: ...
def __delitem__(self, index) -> None: ...
def __contains__(self, item) -> bool: ...
def __add__(self, other) -> list: ...
def __mul__(self, count) -> list: ...
def append(self, item) -> None: ...
def extend(self, iterable) -> None: ...
def insert(self, index, item) -> None: ...
def remove(self, item) -> None: ...
def pop(self, index=-1): ...
def clear(self) -> None: ...
def index(self, item, start=0, stop=None) -> int: ...
def count(self, item) -> int: ...
def sort(self, key=None, reverse=False) -> None: ...
def reverse(self) -> None: ...
def copy(self) -> list: ...
class tuple:
"""Immutable sequence type."""
def __init__(self, iterable=None) -> None: ...
def __len__(self) -> int: ...
def __getitem__(self, index): ...
def __contains__(self, item) -> bool: ...
def __add__(self, other) -> tuple: ...
def __mul__(self, count) -> tuple: ...
def count(self, item) -> int: ...
def index(self, item, start=0, stop=None) -> int: ...
class range:
"""Immutable sequence of numbers."""
def __init__(self, stop) -> None: ...
def __init__(self, start, stop, step=1) -> None: ...
def __len__(self) -> int: ...
def __getitem__(self, index) -> int: ...
def __contains__(self, item) -> bool: ...
@property
def start(self) -> int: ...
@property
def stop(self) -> int: ...
@property
def step(self) -> int: ...
class bytes:
"""Immutable sequence of bytes."""
def __init__(self, source=None, encoding='utf-8', errors='strict') -> None: ...
def __len__(self) -> int: ...
def __getitem__(self, index) -> int: ...
def __contains__(self, item) -> bool: ...
def decode(self, encoding='utf-8', errors='strict') -> str: ...
def hex(self) -> str: ...
@classmethod
def fromhex(cls, string) -> bytes: ...
class bytearray:
"""Mutable sequence of bytes."""
def __init__(self, source=None, encoding='utf-8', errors='strict') -> None: ...
def __len__(self) -> int: ...
def __getitem__(self, index) -> int: ...
def __setitem__(self, index, value) -> None: ...
def __contains__(self, item) -> bool: ...
def append(self, item) -> None: ...
def extend(self, iterable) -> None: ...
def decode(self, encoding='utf-8', errors='strict') -> str: ...class dict:
"""Mutable mapping type."""
def __init__(self, mapping=None, **kwargs) -> None: ...
def __len__(self) -> int: ...
def __getitem__(self, key): ...
def __setitem__(self, key, value) -> None: ...
def __delitem__(self, key) -> None: ...
def __contains__(self, key) -> bool: ...
def get(self, key, default=None): ...
def setdefault(self, key, default=None): ...
def pop(self, key, default=None): ...
def popitem(self) -> tuple: ...
def clear(self) -> None: ...
def keys(self): ...
def values(self): ...
def items(self): ...
def update(self, other) -> None: ...
def copy(self) -> dict: ...
@classmethod
def fromkeys(cls, iterable, value=None) -> dict: ...
class set:
"""Mutable set of unique elements."""
def __init__(self, iterable=None) -> None: ...
def __len__(self) -> int: ...
def __contains__(self, item) -> bool: ...
def add(self, item) -> None: ...
def remove(self, item) -> None: ...
def discard(self, item) -> None: ...
def pop(self): ...
def clear(self) -> None: ...
def copy(self) -> set: ...
def union(self, *others) -> set: ...
def intersection(self, *others) -> set: ...
def difference(self, *others) -> set: ...
def symmetric_difference(self, other) -> set: ...
def update(self, *others) -> None: ...
def intersection_update(self, *others) -> None: ...
def difference_update(self, *others) -> None: ...
def symmetric_difference_update(self, other) -> None: ...
def issubset(self, other) -> bool: ...
def issuperset(self, other) -> bool: ...
def isdisjoint(self, other) -> bool: ...
class frozenset:
"""Immutable set of unique elements."""
def __init__(self, iterable=None) -> None: ...
def __len__(self) -> int: ...
def __contains__(self, item) -> bool: ...
def copy(self) -> frozenset: ...
def union(self, *others) -> frozenset: ...
def intersection(self, *others) -> frozenset: ...
def difference(self, *others) -> frozenset: ...
def symmetric_difference(self, other) -> frozenset: ...
def issubset(self, other) -> bool: ...
def issuperset(self, other) -> bool: ...
def isdisjoint(self, other) -> bool: ...class object:
"""Base class for all Python objects."""
def __init__(self) -> None: ...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
def __hash__(self) -> int: ...
def __eq__(self, other) -> bool: ...
def __ne__(self, other) -> bool: ...
def __getattribute__(self, name): ...
def __setattr__(self, name, value) -> None: ...
def __delattr__(self, name) -> None: ...
class type:
"""Metaclass for all types."""
def __init__(self, object_or_name, bases=(), dict={}) -> None: ...
def __call__(self, *args, **kwargs): ...
def __instancecheck__(self, instance) -> bool: ...
def __subclasscheck__(self, subclass) -> bool: ...
@property
def __name__(self) -> str: ...
@property
def __bases__(self) -> tuple: ...
@property
def __dict__(self) -> dict: ...
class slice:
"""Slice object for sequence indexing."""
def __init__(self, stop) -> None: ...
def __init__(self, start, stop, step=None) -> None: ...
@property
def start(self): ...
@property
def stop(self): ...
@property
def step(self): ...
def indices(self, length) -> tuple: ...
class memoryview:
"""Memory view of bytes-like object."""
def __init__(self, obj) -> None: ...
def __len__(self) -> int: ...
def __getitem__(self, index): ...
def __setitem__(self, index, value) -> None: ...
def tobytes(self) -> bytes: ...
def tolist(self) -> list: ...
def release(self) -> None: ...
@property
def obj(self): ...
@property
def nbytes(self) -> int: ...
@property
def readonly(self) -> bool: ...
@property
def format(self) -> str: ...
@property
def itemsize(self) -> int: ...
@property
def ndim(self) -> int: ...
@property
def shape(self) -> tuple: ...
@property
def strides(self) -> tuple: ...