python-humanize / python-humanize/humanize
Proposal for additional `conjunction` parameter in `natural_list` function
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 756
- Fork
- 148
- Merge medio
- 6g 1h
- PR unite (30g)
- 12
Descrizione
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
- Introduce a new parameter (e.g.,
conjunction) to thenatural_listfunction. - 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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia individuando l’implementazione di natural_list e la relativa documentazione, quindi esamina la discussione correlata nell’issue #103. Conferma come viene prodotta l’uscita predefinita corrente e individua eventuali test o esempi esistenti per natural_list; il lavoro è completato quando viene supportata la congiunzione alternativa richiesta, preservando al contempo il comportamento predefinito corrente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- localization
- Tipo di issue
- Funzionalità
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 42/100