Documentation/Info on this sign

Bart Nessux bart_nessux at hotmail.com
Thu May 20 13:39:02 EDT 2004


Peter Hansen wrote:
> Bart Nessux wrote:
> 
>> Could someone point me to documentation on this (and similar) signs 
>> used in Python:
>>
>> +=
> 
> 
> http://docs.python.org/ref/augassign.html
> 
>> Usage would be:
>>
>> x = += len(y)
> 
> 
> What do you mean by this?  "Usage would be"...  ?
> 
>> Literally, that's "variable x equals 
>> 'funky-symbol-that-I-want-to-learn-about' the length of variable y"
> 
> 
> Huh?  This doesn't have meaning...  both = and += are assignment
> statements, so you can't put one right after the other.
> 
> What are you trying to do?
> 
> -Peter

I'm trying to count files and dirs on a Win XP system... I'm trying to 
do so with a great degree of accuracy. Here's what I've tried:

def fs_object_count():
    file_count = 0
    dir_count = 0
    for root, dirs, files in os.walk(/):
       file_count += len(files)
       dir_count += len(dirs)
    print "Number of Files Examined: ", file_count
    print "Number of Folders Examined: ", dir_count
    print "Total number of FS Objects is:", file_count + dir_count

I've also tried this:

def fs_object_count():
    fs_list = []
    for root, dirs, files in os.walk('/'):
       for d in dirs:
          fs_list.append(d)
       for f in files:
          fs_list.append(f)
    print len(fs_list)

Both functions produce the same results (33,000 files)... the problem: 
the filesystem has twice as many files (66,000) than the actual sums of 
these two counts when doing a virus scan or an adaware scan. To make 
matters more confusing... the IBM Tivoli backup software that I use 
confirms the Python counts when it does a backup. I don't know of a way 
to see what the OS has to say what it thinks is correct. Any ideas on 
how to do this?



More information about the Python-list mailing list