Just want to walk a single directory

2006-01-14 Thread SB
Hi,

I have a super-simple need to just walk the files in a single directory.

I thought this would do it, but "permanentFilelist" ends up containing 
all folders in all subdirectories.

Could someone spot the problem? I've scoured some threads using XNews reg 
expressions involving os.walk, but couldn't extrapolate the answer for my 
need.

===

thebasedir = "E:\\temp"

permanentFilelist= []

for thepath,thedirnames,thefilenames in os.walk(thebasedir):

if thepath != thebasedir:

thedirnames[:] = []

for names in thefilenames:

permanentFilelist.append(names)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Just want to walk a single directory

2006-01-14 Thread SB
Thanks Tim, this definitely does it. I was trying to prevent having to 
spend time absorbing the core of how generators work, because this simple 
is all I need to do, and I don't have the updated python cookbook book. The 
one I have discussed the old os.path.walk.



Tim Peters <[EMAIL PROTECTED]> wrote in 
news:[EMAIL PROTECTED]:

> thebasedir = "C:\\tmpold"
> for dummy, dummy, permanentFilelist in os.walk(thebasedir):
> break

-- 
http://mail.python.org/mailman/listinfo/python-list