PEP Idea: Multi-get for lists/tuples and dictionaries (inspired in NumPy)
Terry Reedy
tjreedy at udel.edu
Thu Mar 19 05:09:32 EDT 2020
On 3/18/2020 10:28 PM, Santiago Basulto wrote:
> For dictionaries it'd even be more useful:
> d = {
> 'first_name': 'Frances',
> 'last_name': 'Allen',
> 'email': 'fallen at ibm.com'
> }
> fname, lname = d[['first_name', 'last_name']]
Insert ordered dicts make this sort of thing less useful.
>>> d = {
'first_name': 'Frances',
'last_name': 'Allen',
'email': 'fallen at ibm.com'
}
>>> fname, lname, _ = d
>>> fname, lname
('first_name', 'last_name')
--
Terry Jan Reedy
More information about the Python-list
mailing list