Ned Deily added the comment:
Yes, I did indeed mean "dir_list", not "root_dir". Sorry for the confusion.
One point: there is no "copied list". "del dir_list" merely deletes the
binding between the name "dir_list" and the list object returned by "os.walk";
the list object itself is unaltered
Sworddragon added the comment:
It sounds like me that "del dir_list" does only delete the copied list while
"del dir_list[:]" accesses the reference and deletes this list. If I'm not
wrong with this assumption I think you was meaning dir_list instead of root_dir
in your post.
But thanks for t
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.cle
New submission from Sworddragon:
The following was tested on Linux. In the attachments is the example code and
here is my output:
sworddragon@ubuntu:/tmp$ ./test.py
1
I'm deleting the list of directories on every recursion and skipping if I'm
directly in /proc (which is theoretically already