python-humanize / python-humanize/humanize

Proposal for additional `conjunction` parameter in `natural_list` function

Offen
#214 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

enhancement
Vorherrschende Sprache
Python
Sterne
756
Forks
148
Ø Merge
6 T. 1 Std.
Gemergte PRs (30 T.)
12

Beschreibung

Thank you for the new version; natural_list really resolves several issues.

Summary

I would like to propose an enhancement to the natural_list function. Currently, the output for the list [1, 2, 3] is formatted as "1, 2 and 3". I propose adding a parameter that allows users to choose between "and" or "or" in the output.

I checked the documentation and found in #103 that there is interest in implementing something like this issue.

Motivation

This enhancement would provide more flexibility in how lists are presented, particularly in contexts where the choice between "and" and "or" is significant.

Proposed Changes
  1. Introduce a new parameter (e.g., conjunction) to the natural_list function.
  2. Accept boolean values for this parameter:
    • True (default behavior)
    • False
Example Usage

With the proposed change, the usage would look like this:

from humanize import natural_list

print(natural_list([1, 2, 3]))  # Output: "1, 2 and 3"
print(natural_list([1, 2, 3], conjunction=False))  # Output: "1, 2 or 3"
Another Idea

We could also consider adding or and and to the i18n support for multiple languages, but I believe that should be addressed in a separate issue.


I could submit the PR if there's interest, but I'm not sure if conjunction would be the best name for this parameter.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, die Implementierung von natural_list und ihre Dokumentation zu finden, und prüfe anschließend die zugehörige Diskussion in Issue #103. Bestätige, wie die aktuelle Standardausgabe erzeugt wird, und ermittle vorhandene Tests oder Beispiele für natural_list; abgeschlossen bedeutet, dass die angeforderte alternative Konjunktion unterstützt wird und dabei das aktuelle Standardverhalten erhalten bleibt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
localization
Issue-Typ
Feature
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.