diff --git a/pep-0428.txt b/pep-0428.txt index 0b5abdd98..86b7f30e6 100644 --- a/pep-0428.txt +++ b/pep-0428.txt @@ -589,10 +589,11 @@ the way. It is the only operation which will remove "``..``" path components. Directory walking ----------------- -Simple (non-recursive) directory access is done by iteration:: +Simple (non-recursive) directory access is done by calling the iterdir() +method, which returns an iterator over the child paths:: >>> p = Path('docs') - >>> for child in p: child + >>> for child in p.iterdir(): child ... PosixPath('docs/conf.py') PosixPath('docs/_templates') @@ -605,7 +606,7 @@ Simple (non-recursive) directory access is done by iteration:: This allows simple filtering through list comprehensions:: >>> p = Path('.') - >>> [child for child in p if child.is_dir()] + >>> [child for child in p.iterdir() if child.is_dir()] [PosixPath('.hg'), PosixPath('docs'), PosixPath('dist'), PosixPath('__pycache__'), PosixPath('build')] Simple and recursive globbing is also provided::