python / python/cpython

`iter()` doesn't require a "collection"

Đang mở
#155,856 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

docs
Ngôn ngữ chính
Python
Star
77.2k
Fork
35.9k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

Documentation

The documentation for iter() says, for the one-argument form:

iter(iterable, /)

Return an iterator object. [...] the single argument must be a collection object which supports the iterable protocol (the __iter__() method), or it must support the sequence protocol (the __getitem__() method with integer arguments starting at 0). If it does not support either of those protocols, TypeError is raised.

This terminology is misleading, since a "collection" also needs to support size and containment checking. Per set and Collections Abstract Base Classes, respectively:

Like other collections, sets support x in set, len(set), and for x in set.

Collection : Sized, Iterable, Container : __contains__, __iter__, __len__

It should be possible to reword this section to avoid the term "collection", either by simply removing it or rephrasing the whole sentence.

Linked PRs
  • gh-155857

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với dạng iter() nhận một đối số trong tài liệu về các hàm tích hợp sẵn. Xem lại cách diễn đạt xung quanh các protocol “iterable” và “sequence”, sau đó xác nhận rằng thuật ngữ “collection” được loại bỏ hoặc diễn đạt lại để không hàm ý hỗ trợ kích thước và phép chứa.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
documentation
Loại issue
Tài liệu
Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
30/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.