Canonical conversion of dict of dicts to list of dicts

Travis Griggs travisgriggs at gmail.com
Tue Mar 30 10:54:30 EDT 2021


> On Mar 30, 2021, at 12:11, Stestagg <stestagg at gmail.com> wrote:
> 
> For completeness, from 3.5 onwards, you can also do the following:
> 
> [{'name': n, **d} for n, d in dod.items()]
> 

Reading through these, personally I like this one best. I'm curious what about it was enabled in 3.5? Was **kwarg expansion inside a dict literal not possible before then? Anyway, I like that it uses simple elemental parts that have been around a long long time in Python.



More information about the Python-list mailing list