Wolfgang Langner added the comment:
Why not implement this pattern with
def dirs(pattern)
and
def files(pattern)
where both are a simple shortcut for
(p for p in mypath.glob(pattern) if p is_file())
or is_dir()
?
--
nosy: +tds333
___
Python
Antoine Pitrou added the comment:
Here is a patch with the proposed API. The API for convenience:
def files(self, include_symlinks=True):
Iterate over the regular files in this directory.
def subdirs(self, include_symlinks=True):
Iterate over the subdirectories
Changes by Antoine Pitrou pit...@free.fr:
--
stage: - patch review
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19767
___
___
Python-bugs-list
Antoine Pitrou added the comment:
Having an `iterdirs()` method next to `iterdir()` is very confusing.
We should find something else, so how about `files()` and `subdirs()`?
--
nosy: +pitrou
___
Python tracker rep...@bugs.python.org
New submission from Jonas H.:
From my personal experience, listing all real files and all subdirectories in
a directory is a very common use case.
Here's a patch that adds the `iterfiles()` and `iterdirs()` methods as a
shortcut for `[f for f in p.iterdir() if f.is_dir/file()]` .
--
STINNER Victor added the comment:
See also issue #11406 which is more generic.
--
nosy: +haypo
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19767
___
R. David Murray added the comment:
Beta is out, so this issue must be targeted for 3.5.
--
nosy: +r.david.murray
versions: +Python 3.5 -Python 3.4
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19767