diff options
author | kj <28750310+Fidget-Spinner@users.noreply.github.com> | 2020-10-20 23:38:08 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-20 23:38:08 (GMT) |
commit | 7cdf30fff39ea97f403b5472096349998d190e30 (patch) | |
tree | e050e285f1f90c671ca1f5dc089c61b9f9205cb0 /Doc/reference/expressions.rst | |
parent | 2d55aa9e37c9c84f4f6a8135d0326da0bcd8f38b (diff) | |
download | cpython-7cdf30fff39ea97f403b5472096349998d190e30.zip cpython-7cdf30fff39ea97f403b5472096349998d190e30.tar.gz cpython-7cdf30fff39ea97f403b5472096349998d190e30.tar.bz2 |
bpo-42010: [docs] Clarify subscription of types (GH-22822)
Diffstat (limited to 'Doc/reference/expressions.rst')
-rw-r--r-- | Doc/reference/expressions.rst | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index 81dd6fc..938a973 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -800,8 +800,8 @@ Subscriptions object: dictionary pair: sequence; item -A subscription selects an item of a sequence (string, tuple or list) or mapping -(dictionary) object: +Subscription of a sequence (string, tuple or list) or mapping (dictionary) +object usually selects an item from the collection: .. productionlist:: python-grammar subscription: `primary` "[" `expression_list` "]" @@ -837,6 +837,17 @@ this method will need to explicitly add that support. A string's items are characters. A character is not a separate data type but a string of exactly one character. +.. + At the time of writing this, there is no documentation for generic alias + or PEP 585. Thus the link currently points to PEP 585 itself. + Please change the link for generic alias to reference the correct + documentation once documentation for PEP 585 becomes available. + +Subscription of certain :term:`classes <class>` or :term:`types <type>` +creates a `generic alias <https://www.python.org/dev/peps/pep-0585/>`_. +In this case, user-defined classes can support subscription by providing a +:meth:`__class_getitem__` classmethod. + .. _slicings: |