[Tutor] threading mind set

bob gailer bgailer at gmail.com
Sun May 13 04:47:00 CEST 2012


def read():
couple of observations
1 - it is customary to put all import statements at the beginning of the 
file.
2 - it is customary to begin variable and function names with a lower 
case letter.
3 - it is better to avoid using built-in function names common method 
names (e.g. read).

def read():
     import csv
     with open('C:\\test\\VDB.csv', 'rb') as somefile:
         read = csv.reader(somefile)
         l = []
         for row in read:
                 l += row
         return l

def DirGetSize(cartella):
     import os
     cartella_size = 0
     for (path, dirs, files) in os.walk(cartella):
         for x in files:
             filename = os.path.join(path, x)
             cartella_size += os.path.getsize(filename)
     return cartella_size

import os.path
for x in read():
     if not os.path.exists(x):
         print ' DOES NOT EXIST ON', x
     else:
         S = DirGetSize(x)
         print 'the file size of', x, 'is',S



-- 
Bob Gailer
919-636-4239
Chapel Hill NC



More information about the Tutor mailing list