Add a `default` argument to `operator.attrgetter` and `operator.itemgetter`
未關閉
還沒有人認領這個 Issue。
extension-modules
stdlib
type-feature
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 35.9k
- PR 合併指標
- PR 指標待擷取
描述
Feature or enhancement
Proposal:
The proposal if for these functions to receive a default argument.
The main motivation is operator.attrgetter, which implements nested attribute access, but is missing getattr's default value support. operator.itemgetter also gets the default argument for consistency.
For operator.attrgetter, only AttributeErrors should be suppressed, and for operator.itemgetter, KeyError.
Has this already been discussed elsewhere?
I have already discussed this feature proposal on Discourse
Links to previous discussion of this feature:
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
先檢視針對 operator.attrgetter 和 operator.itemgetter 提議的行為,接著閱讀連結的 Discourse 討論,以了解尚未解決的設計問題。追蹤這兩個函式現有的實作和測試;完成的標準是支援預設引數,同時僅對 attrgetter 抑制 AttributeError,僅對 itemgetter 抑制 KeyError。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- backend
- Issue 類型
- 功能
- 難度
- 5/5
- 預估耗時
- 一週以上
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100