newbie : prune os.walk

Tim Roberts timr at probo.com
Sat Mar 12 01:44:52 EST 2005


Rory Campbell-Lange <rory at campbell-lange.net> wrote:
>
>Hi. How can I list root and only one level down? I've tried setting dirs
>= [] if root != start root, but it doesn't work. I clearly don't
>understand how the function works. I'd be grateful for some pointers.

The statement
    dir = []
does not actually change the list that was passed in.  It creates a NEW
empty list and binds it to "dir".

If you want to empty the "dir" variable, try:
    del dir[:]
-- 
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list