[issue20764] os.walk recurses down even with dirnames deleted
Ned Deily
report at bugs.python.org
Tue Feb 25 06:50:23 CET 2014
Ned Deily added the comment:
I think you are misunderstanding how del and mutable sequences work. In your code snippet, the del unbinds the name "root_dir" but it does not alter the dirnames list object returned by os.path. Try replacing "del root_dir" with "del root_dir[:]" or "root_dir.clear()".
http://docs.python.org/3/reference/simple_stmts.html#the-del-statement
http://docs.python.org/3/library/stdtypes.html#mutable-sequence-types
----------
nosy: +ned.deily
resolution: -> invalid
stage: -> committed/rejected
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20764>
_______________________________________
More information about the Python-bugs-list
mailing list