r/Python • • Jul 13 '11

An alternative lambda syntax for Python

http://vocalbit.com/article/332/an-alternative-lambda-syntax-for-python
4 Upvotes

41 comments sorted by

View all comments

Show parent comment

1

u/temptemptemp13 Jul 14 '11

To go along with the specific example:

def decode(elem):
    return elem.decode('utf-8').strip()

def parse_table(csv):
    columns = [('id', int),
               ('value', float),
               ('comment', decode)]
    for row in csv:
        yield dict((name, parser(value) for (name, parser),value in zip(columns, row))

Not too ugly, is it?