Canonical conversion of dict of dicts to list of dicts
Jon Ribbens
jon+usenet at unequivocal.eu
Tue Mar 30 07:56:38 EDT 2021
On 2021-03-30, Chris Angelico <rosuav at gmail.com> wrote:
> I dunno about "canonical", but here's how I'd do it:
>
> lod = [info | {"name": name} for name, info in dod.items()]
>
> You could use {"name":name}|info instead if you prefer to have the
> name show up first in the dictionary.
It's probably worth noting this method requires Python 3.9.
More information about the Python-list
mailing list