PEP Idea: Multi-get for lists/tuples and dictionaries (inspired in NumPy)

Rhodri James rhodri at kynesim.co.uk
Thu Mar 19 12:27:44 EDT 2020


On 19/03/2020 14:47, Peter J. Holzer wrote:
> On 2020-03-19 14:24:35 +0000, Rhodri James wrote:
>> On 19/03/2020 13:00, Peter J. Holzer wrote:
>>> It's more compact, especially, if "d" isn't a one-character variable,
>>> but an expression:
>>>
>>>       fname, lname = db[people].employee.object.get(pk=1234)[['first_name', 'last_name']]
>>>
>>> vs.
>>>
>>>       fname = db[people].employee.object.get(pk=1234)['first_name']
>>>       lname = db[people].employee.object.get(pk=1234)['last_name']
>>
>> I have to say I don't think that's more compact at all.  It's too wide
>> to be compact.
> 
> But 83 characters is still more compact than 121 characters.

Only if your sole metric is a strict character count.  Width matters in 
perception; two shorter lines are easier to take in than one long line, 
even if the long line contains fewer characters.

Besides, terseness isn't one of Python's objectives.

-- 
Rhodri James *-* Kynesim Ltd


More information about the Python-list mailing list