map, filter, lambda, list comprehensions (was RE: parameter undefined in procedure)

Michal Wallace (sabren) sabren at manifestation.com
Sun Feb 27 13:00:28 EST 2000


On Sun, 27 Feb 2000, Tim Peters wrote:

> <BEGIN OLD MSG>
>
> > def zip(L1, L2):
> >   return [(x, y) for x in L1, y in L2]

Hey Tim,

is this the same as:


def zip(L1, L2):

    retlist = []

    if len(L1) > len(L2):
        longer, shorter = L1, L2
    else:
        longer, shorter = L2, L1

    for i in len(shorter):
       newlist = [L1[i], L2[i]]
       retlist.append(newlist)

    if longer == L1:
       for i in range(len(L2), len(L2) + (len(L2) - len(L1))):
           newlist = [L1[i], None]
           retlist.append(newlist)
    else:
       for i in range(len(L1), len(L1) + (len(L1) - len(L2))):
           newlist = [None, L2[i]]
           retlist.append(newlist)
       
    return retlist


???


Cheers,

- Michal
-------------------------------------------------------------------------
http://www.manifestation.com/         http://www.linkwatcher.com/metalog/
-------------------------------------------------------------------------





More information about the Python-list mailing list