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

未关闭
#214 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
42/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
python
领域
localization

调研方向

首先定位 natural_list 的实现及其文档,然后查看 issue #103 中的相关讨论。确认当前默认输出是如何生成的,并找出 natural_list 现有的测试或示例;完成的标准是支持所请求的替代连词,同时保留当前的默认行为。

由索引模型根据 Issue 内容生成。

描述

enhancement

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.

主要语言
Python
星标
757
派生
148
平均合并
6 天 1 小时
30 天内合并 PR
12

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

python-humanize/humanize 的其他 Issue

查看 python-humanize/humanize 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。