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(&quot;/python24&quot;):&nbsp;&nbsp;&nbsp; # a comma instead of a period after dirpath<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for file in filenames:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if
file.endswith(&quot;.py&quot;):&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
# py instead of baz, just for my machine<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print
os.path.join(dirpath,file)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
# 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> &lt;<a href="mailto:fant@pobox.com">fant@pobox.com</a>&gt; 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 &quot;find $ROOT -type f -name FOO -print&quot; command&quot;
<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(&quot;/foo/bar&quot;):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for file in filenames:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if file.endswith(&quot;.baz&quot;):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print
os.path.join(dirpath,f)<br><br><br>when I try to run it, I get a &quot;ValueError: too many values to unpack&quot; which I<br>think&nbsp;&nbsp;comes from the fact that there is a subdirectory of /foo/bar which has<br>over 2500 files in it.&nbsp;&nbsp;The tree can't be easily restructured for legacy
<br>reasons.&nbsp;&nbsp;Can anyone suggest the best way to get around this in code?<br><br>Thanks,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Andy<br><br>--<br>Andrew Fant&nbsp;&nbsp;&nbsp;&nbsp;| And when the night is cloudy&nbsp;&nbsp;&nbsp;&nbsp;| This space to let<br>Molecular Geek | There is still a light&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|----------------------
<br><a href="mailto:fant@pobox.com">fant@pobox.com</a>
| That shines on
me&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
| Disclaimer:&nbsp;&nbsp;I don't<br>Boston, MA&nbsp;&nbsp;&nbsp;&nbsp; | Shine until tomorrow, Let it be | even speak for myself<br><br>_______________________________________________<br>Tutor maillist&nbsp;&nbsp;-&nbsp;&nbsp;<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>