bpo-36602: Allow pathlib.Path.iterdir to list recursively by EpicWink · Pull Request #12785 · python/cpython (original) (raw)

Currently, pathlib.Path.iterdir only lists contents of the instance directory. This enhancement allows iterdir to recurse into subdirectories.

The issue references two decisions to be made. I have initially chosen to not yield the contained directories themselves, and I have initially chosen to not resolve paths before checking if they're a directory to be recursed into. Don't hesitate to give criticism on these choices.

In addition, I've decided to make recursive a keyword-only argument, as path.iterdir(True) didn't seem very readable.

https://bugs.python.org/issue36602