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

Peter J. Holzer hjp-python at hjp.at
Thu Mar 19 10:47:00 EDT 2020


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.

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp at hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20200319/d44c9aef/attachment.sig>


More information about the Python-list mailing list