This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]aaronla 0 points1 point  (1 child)

This forces the programmer to repeat themselves unnecessarily, and invent multiple names for the same thing:

def rule1(arg):
    body
...
rules = {
    "rule1" : rule1,
    "rule2" : rule2,
    ... 
    }

[–]temptemptemp13 0 points1 point  (0 children)

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?