Created
April 3, 2009 18:41
-
-
Save inky/89890 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def map_results(fields, rows): | |
keys = [f.split('.')[-1] for f in fields] | |
return tuple(dict(zip(keys, row)) for row in rows) | |
# >>> fields = ('x.id', 'y.name', 'spork') | |
# >>> rows = [(1, 2, 3), (4, 5, 6)] | |
# >>> for row in map_results(fields, rows): | |
# ... print row | |
# ... | |
# {'id': 1, 'name': 2, 'spork': 3} | |
# {'id': 4, 'name': 5, 'spork': 6} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment