Skip to content

Attributes

Attribute access

operator operand
expression function type method type
v = _.k or
v = getattr(_, k)
do_getattr DoesGetattr __getattr__ CanGetattr[+V=object]
_.k = v or
setattr(_, k, v)
do_setattr DoesSetattr __setattr__ CanSetattr[-V=object]
del _.k or
delattr(_, k)
do_delattr DoesDelattr __delattr__ CanDelattr
dir(_) do_dir DoesDir __dir__ CanDir[+R: Iterable[str]]

Instance attributes

attribute attribute type protocol
__annotations__ dict[str, Any] HasAnnotations
D <: Mapping[str, object] HasAnnotations[+D]
__class__ T <: type HasClass[~T]
__code__ types.CodeType HasCode
__dict__ dict[str, Any] HasDict
D <: Mapping[str, object] HasDict[~D]
__doc__ str | None HasDoc
(S <: str) | None HasDoc[+S]
__func__ F <: Callable[..., object] HasFunc[+F]
__module__ str HasModule
S <: str HasModule[+S]
__name__ str HasName
S <: str HasName[~S]
__objclass__ type HasObjclass
T <: type HasObjclass[+T]
__qualname__ str HasQualname
S <: str HasQualname[~S]
__self__ object HasSelf
T HasSelf[+T]
__type_params__ TypeParams HasTypeParams
Ts <: TypeParams HasTypeParams[~Ts]
__wrapped__ F <: Callable[..., object] HasWrapped[+F]

Here, type TypeParams = tuple[TypeVar | ParamSpec | TypeVarTuple, ...].

HasNames

type HasNames[N: str = str, Q: str = N] = HasName[N] & HasQualname[Q]

Class attributes

attribute attribute type protocol
__match_args__ tuple[LiteralString, ...] | list[LiteralString] HasMatchArgs
__slots__ LiteralString | Iterable[LiteralString] HasSlots