12 Apr
2018
12 Apr
'18
3:15 p.m.
12.04.18 17:34, Ed Kellett пише:
It allows for creating a flattened dict from an iterable of dicts, too, which I've occasionally wanted:
configs = {'a': 'yes'}, {'b': 'no'}, {'c': 3} dict(*configs) {'a': 'yes', 'b': 'no', 'c': 3}
versus:
dict(chain.from_iterable(c.items() for c in configs)) {'a': 'yes', 'b': 'no', 'c': 3}
Or {**x for x in configs}.