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 @@ -800,8 +800,8 @@ Subscriptions
800
800
object: dictionary
801
801
pair: sequence; item
802
802
803
- A subscription selects an item of a sequence (string, tuple or list) or mapping
804
- (dictionary) object:
803
+ Subscription of a sequence (string, tuple or list) or mapping (dictionary)
804
+ object usually selects an item from the collection :
805
805
806
806
.. productionlist :: python-grammar
807
807
subscription: `primary ` "[" `expression_list ` "]"
@@ -837,6 +837,17 @@ this method will need to explicitly add that support.
837
837
A string's items are characters. A character is not a separate data type but a
838
838
string of exactly one character.
839
839
840
+ ..
841
+ At the time of writing this, there is no documentation for generic alias
842
+ or PEP 585. Thus the link currently points to PEP 585 itself.
843
+ Please change the link for generic alias to reference the correct
844
+ documentation once documentation for PEP 585 becomes available.
845
+
846
+ Subscription of certain :term: `classes <class> ` or :term: `types <type> `
847
+ creates a `generic alias <https://www.python.org/dev/peps/pep-0585/ >`_.
848
+ In this case, user-defined classes can support subscription by providing a
849
+ :meth: `__class_getitem__ ` classmethod.
850
+
840
851
841
852
.. _slicings :
842
853
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