Andrew,<br>
<br>
I put in your code, exactly as you have it, with only three changes:<br>
<br>
#!/usr/bin/python<br>
import os<br>
<br>
for (dirpath, subdirs, filenames) in os.walk("/python24"): # a comma instead of a period after dirpath<br>
for file in filenames:<br>
if
file.endswith(".py"):
# py instead of baz, just for my machine<br>
print
os.path.join(dirpath,file)
# file instead of f<br><br>
This walks the directories and prints out the path and filename.<br>
<br>
On a side note I've never had a problem throwing several thousand files or lines at python.<br>
<br><div><span class="gmail_quote">On 1/30/06, <b class="gmail_sendername">Andrew D. Fant</b> <<a href="mailto:fant@pobox.com">fant@pobox.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I'm working on a program to do some processing on a directory tree. If I had<br>been doing it in a shell script, the core of the processing would have been in<br>a "find $ROOT -type f -name FOO -print" command"
<br><br>On the web, I found a snippet of code that demonstrated the os.walk module and<br>I created a simple test program to work on my tree that looked like this:<br><br>#!/usr/bin/python<br>import os<br><br>for (dirpath. subdirs, filenames) in
os.walk("/foo/bar"):<br> for file in filenames:<br> if file.endswith(".baz"):<br> print
os.path.join(dirpath,f)<br><br><br>when I try to run it, I get a "ValueError: too many values to unpack" which I<br>think comes from the fact that there is a subdirectory of /foo/bar which has<br>over 2500 files in it. The tree can't be easily restructured for legacy
<br>reasons. Can anyone suggest the best way to get around this in code?<br><br>Thanks,<br> Andy<br><br>--<br>Andrew Fant | And when the night is cloudy | This space to let<br>Molecular Geek | There is still a light |----------------------
<br><a href="mailto:fant@pobox.com">fant@pobox.com</a>
| That shines on
me
| Disclaimer: I don't<br>Boston, MA | Shine until tomorrow, Let it be | even speak for myself<br><br>_______________________________________________<br>Tutor maillist - <a href="mailto:Tutor@python.org">Tutor@python.org
</a><br><a href="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor</a><br></blockquote></div><br>