Search notes:

Python: dunders

Dunders are names with two leading and two trailing underscords such as __init__ or __version__.
__aenter__ and __aexit__ These dunders are present in an asynchronous context manager (see async with).
__annotations__
__bases__ A class's immediate parent classes. Compare with
__bool__ If an object has a __bool__ method, the value that this method returns determines if an object is considered to be True or False when evaluated in a boolean context.
__builtins__ contains built-in functions, exceptions and other objects.
__call__ An object that implements __call__ becomes a callable object.
__class__ a reference of an instance's type. Compare with the built-in function type
__debug__
__deepcopy__ ?
__del__() called when an object's reference counter reaches zero.
__dict__
__dir__()
__doc__
__enter__()
__exit__()
__file__ corresponds to the pathname where a Python script or module was loaded from.
__getattr__ called if a user of an object tries to access a member of method on that object that does not exist.
? __getitem__
__init__
__init_subclass__ called when a subclass (not an instance) of a class is being created.
__iter__() Any object that has an __iter__ method is an iterable.
? __len__
__loader__
__lt__ lt stands for less than and defines how the < operator behaves when applied between two objects.
__mro__ mro for method resolution order. Compare with __bases__.
__next__
__package__
__path__ A module with a __path__ is considered a package.
__repr__
__reversed__() Using __reversed__() is a possibility to implement the protocol that is required by the reversed() built-in function.
__setattr__
__spec__
__str__
__weakref__
__add__, __mul__ etc. Mathematical dunders allow to «overload» +, * etc.

Index