Wording and typos

This commit is contained in:
David Peter
2025-02-20 09:57:48 +01:00
parent b6f9af15e5
commit f2be4d4385
2 changed files with 7 additions and 5 deletions

View File

@@ -23,8 +23,8 @@ object (in which case it is `None`), or from an instance (in which case it is th
- `C().f` is equivalent to `getattr_static(C, "f").__get__(C(), C)`
Here, `inspect.getattr_static` is used to bypass the descriptor protocol and directly access the
function attribute. The way the special `__get__` method *on functions* works like is as follows. In
the former case, if the `instance` attribute is `None`, it simply returns the function itself. In
function attribute. The way the special `__get__` method *on functions* works is as follows. In the
former case, if the `instance` argument is `None`, `__get__` simply returns the function itself. In
the latter case, it returns a *bound method* object:
```py

View File

@@ -83,9 +83,11 @@ reveal_type(c.flexible_int) # revealed: int | None
## Data and non-data descriptors
Descriptors that define `__set__` or `__delete__` are called *data descriptors* (e.g. properties),
while those that only define `__get__` are called non-data descriptors (e.g. functions,
`classmethod` or `staticmethod`).
Descriptors that define `__set__` or `__delete__` are called *data descriptors*. An example\
of a data descriptor is a `property` with a setter and/or a deleter.\
Descriptors that only define `__get__`, meanwhile, are called *non-data descriptors*. Examples
include\
functions, `classmethod` or `staticmethod`).
The precedence chain for attribute access is (1) data descriptors, (2) instance attributes, and (3)
non-data descriptors.