MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/Python/comments/iohrl/an_alternative_lambda_syntax_for_python/c25ect8/?context=3
r/Python • u/vocalbit • Jul 13 '11
41 comments sorted by
View all comments
7
What will you do when you want to put a lambda function in a list? Example:
def parse_table(csv): columns = [('id', int), ('value', float), ('comment', lambda elem:elem.decode('utf-8').strip())] for row in csv: yield dict((name, parser(value) for (name, parser),value in zip(columns, row))
This is great when parsing things like csv tables or whatever, so it is actually useful.
4 u/joehillen Jul 13 '11 Easily one of my favorite uses for lambda.
4
Easily one of my favorite uses for lambda.
7
u/Liorithiel Jul 13 '11 edited Jul 13 '11
What will you do when you want to put a lambda function in a list? Example:
This is great when parsing things like csv tables or whatever, so it is actually useful.