Gallery
Python Info
Share
Explore

icon picker
Python Dunders

A compilaton of all Python dunder definitions with some key attributes

Search
Name
Category
Start
End
Writable
Called
Returns
Usage
Package
URL
__ilshift__
x <<= y
__invert__
~x
__irshift__
x >>= y
__ixor__
x ^= y
__lshift__
x << y
__rlshift__
y << x
__rrshift__
y >> x
__rshift__
x >> y
__annotations__
A dict containing annotations of parameters. The keys of the dict are the parameter names, and 'return' for the return annotation, if provided. For more information on working with this attribute, see Annotations Best Practices.
__call__
x()
__closure__
None or a tuple of cells that contain bindings for the function’s free variables. See below for information on the cell_contents attribute.
__code__
The code object representing the compiled function body.
__defaults__
A tuple containing default argument values for those arguments that have defaults, or None if no arguments have a default value.
__globals__
A reference to the dictionary that holds the function’s global variables — the global namespace of the module in which the function was defined.
__kwdefaults__
A dict containing defaults for keyword-only parameters.
__bool__
bool(x)
__bytes__
bytes(x)
__complex__
complex(x)
__float__
float(x)
__hash__
hash(x)
__int__
int(x)
__iter__
iter(x)
__nonzero__
Like __bool__
__cmp__
__eq__
x == y
__ge__
x >= y
__gt__
x > y
__instancecheck__
isinstance(y, x) Defined for x's metaclass
__le__
x <= y
__lt__
x < y
__ne__
x != y
__subclasscheck__
issubclass(y, x)
__subclasshook__
issubclass(y, x), called for x if x is derived from ABC
__enter__
with x:
__exit__
with x:
__del__
__del__ is a finalizer. It is called when an object is garbage collected which happens at some point after all references to the object have been deleted.
__delattr__
Called for A when calling del A.x
__delitem__
Called for A when calling del A[n] or A[n:n] in which case a slice object is given as key
__delslice__
__delete__
del X.y will call y's __delete__ (property)
__get__
X.y = Y(), X.y will call y's __get__ (property)
__set__
X.y = Y(), X.y = z will call y's __set__ (property)
__all__
module.__all__, decides what's exported by module
__bases__
Returns a list of classes that X has directly inherited from
__class__
type(x)[y]
__dict__
The namespace supporting arbitrary function attributes.
__doc__
The function’s documentation string, or None if unavailable; not inherited by subclasses.
__module__
The name of the module the function was defined in, or None if unavailable.
__name__
The function’s name.
__qualname__
The function’s qualified name.
__sizeof__
sys.getsizeof(x), Internal size in bytes
__slots__
__subclasses__
Returns a list of classes that directly inherited X
__contains__
x in y
__getitem__
A[n]
__getslice__
__index__
list[x] calls x.__index__
__len__
len(x), also called by bool(x), guessing it's cause empty iterables should return False
__length_hint__
Estimate of len if len(x) raises TypeError, defined in iterators
__missing__
class X(dict) X()["missing"] Only works for subclass of dict, called if key is missing
__next__
next(x)
__reversed__
reversed(x), if not defined then len and getitem will be used
__setitem__
A[n] = x
__setslice__
__and__
x & y
__iand__
x &= y
__ior__
x |= y
__or__
x | y
__rand__
y & x, used if y hasn't implemented it or if that returns NotImplementedError
__ror__
y | x, used if y hasn't implemented it or if that returns NotImplementedError
__rxor__
y ^ x, used if y hasn't implemented it or if that returns NotImplementedError
__xor__
x ^ y
__class_getitem__
X[n]
__dir__
dir(x)
__getattr__
Called for attrs that aren't already defined.
__getattribute__
Called unconditionally to implement attribute accesses for instances of the class.
__setattr__
A.y = x
__abs__
abs(x)
__add__
x + y
__ceil__
math.ceil(x)
__divmod__
divmod(x, y) -> (i, j)
__floor__
math.floor(x)
__floordiv__
x // y
__iadd__
x += y
__ifloordiv__
x //= y
__imod__
x %= y
__imul__
x *= y
__ipow__
x **= y
__isub__
x -= y
__itruediv__
x /= y
__mod__
x % y
__mul__
x * y
__neg__
-x
__pos__
+x
__pow__
pow(x, y)
__radd__
y + x, used if y hasn't implemented it or if that returns NotImplementedError
__rdiv__
y / x, used if y hasn't implemented it or if that returns NotImplementedError
__rdivmod__
divmod(y, x), used if y hasn't implemented it or if that returns NotImplementedError
__rfloordiv__
y // x, used if y hasn't implemented it or if that returns NotImplementedError
__rmod__
y % x, used if y hasn't implemented it or if that returns NotImplementedError
__rmul__
y * x, used if y hasn't implemented it or if that returns NotImplementedError
__round__
round(x)
__rpow__
pow(y, x), used if y hasn't implemented it or if that returns NotImplementedError
__rsub__
y - x, used if y hasn't implemented it or if that returns NotImplementedError
__rtruediv__
y / x, used if y hasn't implemented it or if that returns NotImplementedError
__sub__
x - y
__truediv__
x / y
__trunc__
math.trunc(x), floors positive, ceils negative
__imatmul__
x @= y
__matmul__
x @ y
__rmatmul__
y @ x, used if y hasn't implemented it or if that returns NotImplementedError
__init__
cls()
__init_subclass__
class Y(X): called for X if something inherits it
__new__
Called before init to create object of class without parameters
__prepare__
Return namespace for metaclass
__set_name__
class Y: foo = X() Called for X, attr has to be defined within class scope
__getnewargs__
return a tuple of how to call __new__ with pickle.loads(str), positional only
__getnewargs_ex__
Like __getnewargs__ but key-word only
__getstate__
__dict__ is pickled if this isn't defined, otherwise return obj is pickled
__reduce__
Low level interface for pickling, alternative to __getstate__ and __setstate__. Takes no parameters
__reduce_ex__
Takes presedence over __reduce__, takes one integer as parameter (the protocol number)
__setstate__
Returns new __dict__ for unpickled obj
__format__
"{0}".format(4) or format(X)
__fspath__
os.fspath(x)
__repr__
repr(x)
__str__
str(x)
__aenter__
async with X():
__aexit__
async with X():
__aiter__
__anext__
__await__
Used by asyncio, usually not needed
There are no rows in this table

Share
 
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.