Re: os.walk() dirs and files

2006-02-08 Thread rtilley
George Sakkis wrote: > Or a bit more efficiently (no need to allocate a new list for storing > files+dirs): > > from itertools import chain > for root, dirs, files in os.walk(path): > for fs_object in chain(files,dirs): > ADD fs_object to dictionary I like that! itertools is

Re: os.walk() dirs and files

2006-02-08 Thread Tim Peters
[rtilley] > When working with file and dir info recursively on Windows XP. I'm going > about it like this: > > for root, dirs, files in os.walk(path): > for f in files: > ADD F to dictionary > for d in dirs: > ADD D to dictionary > > Is it possible to do something such a

Re: os.walk() dirs and files

2006-02-08 Thread George Sakkis
rtilley wrote: > Duncan Booth wrote: > >> How about just concatentating the two lists: >> >>> for root, dirs, files in os.walk(path): >> >>for fs_object in files + dirs: >> >>> ADD fs_object to dictionary > > > Thank you Duncan! that solves the problem perfectly! Or a bit more effi

Re: os.walk() dirs and files

2006-02-08 Thread Duncan Booth
rtilley wrote: > Just to clarify. In this particular case, I do not need to differentiate > between files and dirs... so would it be possible to do something such > as this: > How about just concatentating the two lists: > for root, dirs, files in os.walk(path): > for fs_object in files,

Re: os.walk() dirs and files

2006-02-08 Thread rtilley
rtilley wrote: > Hello, > > When working with file and dir info recursively on Windows XP. I'm going > about it like this: > > for root, dirs, files in os.walk(path): > for f in files: > ADD F to dictionary > for d in dirs: > ADD D to dictionary > > Is it possible to do

Re: os.walk() dirs and files

2006-02-08 Thread rtilley
Duncan Booth wrote: > How about just concatentating the two lists: > >>for root, dirs, files in os.walk(path): >for fs_object in files + dirs: >> ADD fs_object to dictionary Thank you Duncan! that solves the problem perfectly! -- http://mail.python.org/mailman/listinfo/python-li

os.walk() dirs and files

2006-02-08 Thread rtilley
Hello, When working with file and dir info recursively on Windows XP. I'm going about it like this: for root, dirs, files in os.walk(path): for f in files: ADD F to dictionary for d in dirs: ADD D to dictionary Is it possible to do something such as this: for root,