gh-155856: Rephrase doc for "iter" to avoid "collection" - #155857
gh-155856: Rephrase doc for "iter" to avoid "collection"#155857wjandrea wants to merge 1 commit into
Conversation
Documentation build overview
|
Fixes python#155856 - The term "collection" is misleading. Also add link to "sequence".
picnixz
left a comment
There was a problem hiding this comment.
Ah I overlooked the "term" around the sequence. Ok.
| the sequence protocol (the :meth:`~object.__getitem__` method with integer arguments | ||
| second argument, the single argument must be an object that supports the | ||
| :term:`iterable` protocol (the :meth:`~object.__iter__` method) or the | ||
| :term:`sequence` protocol (the :meth:`~object.__getitem__` method with integer arguments |
There was a problem hiding this comment.
Linking to the sequence glossary entry isn't quite correct here, it has stricter requirements (i.e., a __len__ method) than iter()'s requirements.
There was a problem hiding this comment.
Oh we have a discrepancy between Sequence protocol in collections.abc and the one in C then: https://docs.python.org/3/c-api/sequence.html#c.PySequence_Check
There was a problem hiding this comment.
Also, we say:
The sequence iteration protocol (used, for example, in for loops), expects that an IndexError will be raised for illegal indexes to allow proper detection of the end of a sequence.
So I'km not sure you need __len__
There was a problem hiding this comment.
Actually, I think it's the C page which should mentions the __len__ as well.
A link to the sequence protocol was actually incorrect.
Fixes #155856 - The term "collection" is misleading.
Also add link to "sequence".
iter()doesn't require a "collection" #155856