-
-
Notifications
You must be signed in to change notification settings - Fork 30.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-45680: Improve docs on subscriptions w.r.t. GenericAlias
objects
#29479
Conversation
GenericAlias
objects
GenericAlias
objectsGenericAlias
objects
GenericAlias
objectsGenericAlias
objects
@JelleZijlstra, reckon this can be merged soon? :) |
Looking at this again I'm not so sure, sorry. This adds more text than was there before, but the new text is a little repetitive. I do like the additional links though. I feel like a broader problem with the language reference is that it veers too much into describing how concrete built-in types handle an operation, and not enough into how exactly the operation works. Here, for example, there is no precise description of when |
See also bpo-46754. |
Thanks for taking a look! I'll have a think tomorrow about whether I want to try revising this PR, or just close it. |
Perhaps you're right that that information might be better found in this document, but tbqh I don't have the energy to move that section from the data model to here after spending so long adding that section to the data model in GH-29389 :( |
@JelleZijlstra I've had another bash at it. I've tried to make the section less repetitive and increase the accuracy of the section regarding the "expression list". The core aims of this PR are to:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Just one comment.
@@ -815,30 +815,44 @@ Subscriptions | |||
object: dictionary | |||
pair: sequence; item | |||
|
|||
Subscription of a sequence (string, tuple or list) or mapping (dictionary) | |||
object usually selects an item from the collection: | |||
The subscription of an instance of a :ref:`container class <sequence-types>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems weird to link this to sequence types. Maybe just drop the link? The later explanation is clearer about sequences and mappings.
The subscription of an instance of a :ref:`container class <sequence-types>` | |
The subscription of an instance of a container class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the section in the docs linked to with sequence-types
perhaps originally only discussed sequence types. Now, however, it discusses all kinds of container types -- the link takes us to here: https://docs.python.org/3/reference/datamodel.html#emulating-container-types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I'm happy to merge this now (cc @gvanrossum).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Because the other meaning of "subscription" (e.g. a magazine) is so much more common I have a slight problem with using it to refer to the a[i] syntax, but it seems commonly used in our docs so it's fine. And the unambiguous alternative, "subscripting", is used much less frequently in our docs.)
Thanks @AlexWaygood for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10. |
GH-31743 is a backport of this pull request to the 3.10 branch. |
GH-31744 is a backport of this pull request to the 3.9 branch. |
pythonGH-29479) (cherry picked from commit 5073129) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
pythonGH-29479) (cherry picked from commit 5073129) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
pythonGH-29479) (cherry picked from commit 5073129) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Thanks so much for helping get this over the line @JelleZijlstra! |
pythonGH-29479) (cherry picked from commit 5073129) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This PR is part of the project to improve documentation on
GenericAlias
objects and__class_getitem__
, started in #29335.https://bugs.python.org/issue45680