`enumerate` and `filter` documentation should explicitly mention that they accept any iterable
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 36k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
The documentation of enumerate(iterable, start=0) currently reads:
Return an enumerate object. iterable must be a sequence, an iterator, or some other object which supports iteration. The
__next__()method of the iterator returned byenumerate()returns a tuple containing a count (from start which defaults to 0) and the values obtained from iterating over iterable.
This wording dates back to 2002 (commit 38f71973) with minimal changes ('the values obtained' was originally 'the corresponding value obtained', which was slightly more accurate in my opinion). An earlier issue about this paragraph can be found at #66914, though the specific issue at hand, the description of iterable's type, was not really discussed there.
While the parameter name indicates that enumerate accepts any iterable as the first argument, I find it strange that the description explicitly lists
a sequence, an iterator, or some other object which supports iteration
instead of/without actually mentioning 'iterable' and referencing the term's definition in the glossary.
My primary suggestion is to replace (the slightly vague, as it could mean iterable or iterator) 'object which supports iteration' with 'iterable' and a link to the glossary. Additionally, since all iterators are iterables, their mention could also be removed.
Suggestion 1 (with or without a link for 'iterator'):
iterable must be a sequence, an iterator, or some other iterable.
Suggestion 2:
iterable must be a sequence or some other iterable.
filter has a similar situation:
iterable may be either a sequence, a container which supports iteration, or an iterator.
'A container which supports iteration' is quite vague and mildly misleading since other parts of the documentation use the term 'container' for lists and similar types. It also uses 'may' instead of 'must'. I would suggest to use the same wording there as for enumerate.
Linked PRs
- gh-101771
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Prüfe zuerst den verknüpften PR gh-101771 und sieh dir dann die Dokumentationseinträge für enumerate und filter sowie deren bestehende Formulierung an. Erledigt ist die Aufgabe, wenn beide Einträge ausdrücklich die Annahme eines Iterables beschreiben und die angeforderte Glossarterminologie konsistent verwenden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- documentation
- Issue-Typ
- Dokumentation
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 30/100