[Python-ideas] Unpacking a dict

Guido van Rossum guido at python.org
Wed May 25 22:18:41 EDT 2016


On Wed, May 25, 2016 at 6:56 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> On Wed, May 25, 2016 at 01:11:35PM +0000, Michael Selik wrote:
> What is your evidence for this claim? So far I've only seen one real-
> world use-case for this, and that single use-case would be well served
> by a simpler syntax:
>
> a, b, c = **mapping

I have to warn here. This looks cool but it does something that AFAIK
no other Python syntax uses -- it takes variable names and does
something to those variables but *also* uses their actual names as
string literals. I agree that the use cases for this seem pretty
sweet, but perhaps we should give it a somewhat different syntax just
so it's clear that the names on the LHS matter. The precedent that the
targets must be actual names rather than anything you can assign to is
also kind of scary.

-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-ideas mailing list