Skip to content

Documentation typo for pathlib.Path.walk in Python 3.12 #96279

@SimpleArt

Description

@SimpleArt

Documentation

In the documentation for pathlib.Path.Walk, there is a typo in the provided example's keyword argument that should be top_down=False:

# Delete everything reachable from the directory "top".
# CAUTION:  This is dangerous! For example, if top == Path('/'),
# it could delete all of your files.
for root, dirs, files in top.walk(topdown=False):
    for name in files:
        (root / name).unlink()
    for name in dirs:
        (root / name).rmdir()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions