[issue11406] There is no os.listdir() equivalent returning generator instead of list
STINNER Victor
report at bugs.python.org
Mon May 6 01:16:39 CEST 2013
STINNER Victor added the comment:
size = 0
for name, st in scandir(path):
if st.st_mode is None or st.st_size is None:
st = os.stat(os.path.join(path, name))
if stat.S_ISREG(st.st_mode):
size += st.st_size
It would be safer to use dir_fd parameter when supported, but I don't
think that os.scandir() should care of this problem. An higher level
API like pathlib, walkdir & cie which should be able to reuse *at() C
functions using dir_fd parameter.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11406>
_______________________________________
More information about the Python-bugs-list
mailing list