File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
Misc/NEWS.d/next/Documentation Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -796,8 +796,8 @@ Subscriptions
796
796
object: dictionary
797
797
pair: sequence; item
798
798
799
- A subscription selects an item of a sequence (string, tuple or list) or mapping
800
- (dictionary) object:
799
+ Subscription of a sequence (string, tuple or list) or mapping (dictionary)
800
+ object usually selects an item from the collection :
801
801
802
802
.. productionlist :: python-grammar
803
803
subscription: `primary ` "[" `expression_list ` "]"
@@ -833,6 +833,17 @@ this method will need to explicitly add that support.
833
833
A string's items are characters. A character is not a separate data type but a
834
834
string of exactly one character.
835
835
836
+ ..
837
+ At the time of writing this, there is no documentation for generic alias
838
+ or PEP 585. Thus the link currently points to PEP 585 itself.
839
+ Please change the link for generic alias to reference the correct
840
+ documentation once documentation for PEP 585 becomes available.
841
+
842
+ Subscription of certain :term: `classes <class> ` or :term: `types <type> `
843
+ creates a `generic alias <https://www.python.org/dev/peps/pep-0585/ >`_.
844
+ In this case, user-defined classes can support subscription by providing a
845
+ :meth: `__class_getitem__ ` classmethod.
846
+
836
847
837
848
.. _slicings :
838
849
Original file line number Diff line number Diff line change
1
+ Clarify that subscription expressions are also valid for certain
2
+ :term: `classes <class> ` and :term: `types <type> ` in the standard library, and
3
+ for user-defined classes and types if the classmethod
4
+ :meth: `__class_getitem__ ` is provided.
You can’t perform that action at this time.
0 commit comments