Skip to content

Improve pathlib.Path.iterdir docstring #98832

Closed

Description

@sobolevn

Right now it says:

cpython/Lib/pathlib.py

Lines 871 to 876 in e089f23

def iterdir(self):
"""Iterate over the files in this directory. Does not yield any
result for the special paths '.' and '..'.
"""
for name in os.listdir(self):
yield self._make_child_relpath(name)

This part is confusing:

Does not yield any result for the special paths '.' and '..'

It might be understood as Path('.').iterdir() not yileding any results.

I think, that it would be better to use the exact same wording as in docs: https://docs.python.org/3/library/pathlib.html#pathlib.Path.iterdir

the special entries '.' and '..' are not included.

I will send a PR.

Activity

  1. added
    docsDocumentation in the Doc dir
    stdlibStandard Library Python modules in the Lib/ directory
    on Oct 28, 2022
  2. self-assigned this
    on Oct 28, 2022
  3. added a commit that references this issue on Oct 28, 2022
  4. added a commit that references this issue on Nov 9, 2022
  5. AlexWaygood commented on Nov 9, 2022

    @AlexWaygood
    Member

    Thanks @sobolevn!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

stdlibStandard Library Python modules in the Lib/ directorytopic-pathlib

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions