This file contains hidden or 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
bazById = {baz.id: baz for baz in foo.bazs} | |
foo.bar.bazs = {bazById[k]:v for k, v in foo.bar.bazs.items()} |
This file contains hidden or 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 myfunc(foo): | |
... | |
barById = {b.id: b for b in foo.bar.bazs.keys()} | |
... |
This file contains hidden or 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
import json | |
from collections import namedtuple | |
x = json.loads(data, object_hook=lambda d: namedtuple('X', d.keys())(*d.values())) |
NewerOlder