[Tutor] Re: Tutor Digest, Vol 7, Issue 34

kiran at mhowlinux.org kiran at mhowlinux.org
Fri Feb 13 12:16:32 EST 2004


couple of problems here

1. elif is not followed by a ":" but another condition
2. u have used file_size and files_size ( one with an s and another without
an s..check that)
3. figure out logical errors...i will give you an edited piece of your
code...which runs...but there would  still be some errors..the way u are
getting the file sizes

def get_size(n,dir):
    import os
    files_size = []
    biggest_files = []
    files = os.listdir(dir)
    files = filter(lambda x:not os.path.isdir(x) and
            not os.path.islink(x),files)

    for f in range(len(files)):
        files_size = files_size + [(files[f],os.path.getsize(files[f]))]

    for b in range(len(files_size)):
        if files_size[b][1] > files_size[b+1][1]:
            biggest_files = biggest_files + files_size[b]
        elif (files_size[b][1] == files_size[b+1][1]):
            biggest_files = biggest_files + files_size[b][1] +
files_size[b][1]
        else:
            biggest_files = biggest_files + files_size[b+1]





Beware the lollipop of mediocrity: lick it once and you suck forever
<a href="http://www.mhowlinux.org/home">www.mhowlinux.org</a> Helping Linux
users in Mhow

couple of problems here

1. elif is not followed by a ":" but another condition
2. u have used file_size and files_size ( one with an s and another without
an s..check that)
3. figure out logical errors...i will give you an edited piece of your
code...which runs...but there would  still be some errors..the way u are
getting the file sizes

def get_size(n,dir):
    import os
    files_size = []
    biggest_files = []
    files = os.listdir(dir)
    files = filter(lambda x:not os.path.isdir(x) and
            not os.path.islink(x),files)

    for f in range(len(files)):
        files_size = files_size + [(files[f],os.path.getsize(files[f]))]

    for b in range(len(files_size)):
        if files_size[b][1] > files_size[b+1][1]:
            biggest_files = biggest_files + files_size[b]
        elif (files_size[b][1] == files_size[b+1][1]):
            biggest_files = biggest_files + files_size[b][1] +
files_size[b][1]
        else:
            biggest_files = biggest_files + files_size[b+1]





Beware the lollipop of mediocrity: lick it once and you suck forever
<a href="http://www.mhowlinux.org/home">www.mhowlinux.org</a> Helping Linux
users in Mhow




More information about the Tutor mailing list