[Python-ideas] Enhancing dict.values

Michael Selik michael.selik at gmail.com
Fri May 27 11:02:15 EDT 2016


On Thu, May 26, 2016 at 11:39 PM Steven D'Aprano <steve at pearwood.info>
wrote:

> On Thu, May 26, 2016 at 11:28:25PM +0100, Nathan Schneider wrote:
>
> > Instead of special syntax, what if dict.values() returned a tuple when
> > given keys as arguments:
> >
> >    partner_id, product_id, ship_to, product_ids = my_dict.values(
> >            'partner_id', 'product_id', 'ship_to', 'product_ids')
>
>
> I like this idea. I think it beats the status quo:
>

Isn't this the status quo?
    a, b, c = [mapping[k] for k in ('a', 'b', 'c')]

That was already someone's argument that a special dict unpacking syntax is
unnecessary.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160527/58c65185/attachment.html>


More information about the Python-ideas mailing list