# L-23 MCS 260 Fri 19 Oct 2007 : maxfile.py # # This program prints the name of the largest # file in the current directory. # import os.path L = os.listdir('.') if len(L) == 0: print 'empty directory' else: max = os.path.getsize(L[0]) name = L[0] for k in range(1,len(L)): s = os.path.getsize(L[k]) if s > max: max = s name = L[k] print 'largest file ' + name \ + ' has ' + str(max) + ' bytes'