python-humanize / python-humanize/humanize
Proposal for additional `conjunction` parameter in `natural_list` function
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 756
- Forks
- 148
- Merge moyen
- 6 j 1 h
- PR mergées (30 j)
- 12
Description
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.
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par localiser l’implémentation de natural_list et sa documentation, puis examinez la discussion associée dans l’issue #103. Confirmez comment la sortie par défaut actuelle est produite et identifiez les tests ou exemples existants pour natural_list ; le travail est considéré comme terminé lorsque la conjonction alternative demandée est prise en charge tout en préservant le comportement par défaut actuel.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- localization
- Type d'issue
- Fonctionnalité
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 42/100