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}.

_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to