[Python-ideas] Accepting multiple mappings as positional arguments to create dicts

Serhiy Storchaka storchaka at gmail.com
Thu Apr 12 11:15:58 EDT 2018


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



More information about the Python-ideas mailing list