count files in a directory

rbt rbt at athop1.ath.vt.edu
Fri May 20 23:08:27 EDT 2005


James Stroud wrote:
> def count_em(valid_path):
>   root, dirs, files = os.walk(valid_path)
>   return len(files)

Here's another Tback:

 >>> Traceback (most recent call last):
   File "C:\Program 
Files\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, 
in RunScript
     exec codeObject in __main__.__dict__
   File "C:\Documents and Settings\rbt\Desktop\newa\replicate.py", line 62, in ?
     A = count_em(X)
   File "C:\Documents and Settings\rbt\Desktop\newa\replicate.py", line 56, in count_em
     root, dirs, files = os.walk(valid_path)
ValueError: need more than 2 values to unpack




More information about the Python-list mailing list