[Python-ideas] Unpacking a dict

Ethan Furman ethan at stoneleaf.us
Mon May 30 23:00:41 EDT 2016


On 05/30/2016 08:07 AM, Nikolaus Rath wrote:
> On May 29 2016, Guido van Rossum <guido-+ZN9ApsXKcEdnm+yROfE0A at public.gmane.org> wrote:
>>> using other words still on the table?
>>>
>>>   d = {"foo": 42}
>>>   <something> d <something> 42 # or the other way around
>>>   assert foo == 42
>>
>> This I don't understand -- why would the '42' appear in the extraction
>> syntax? I guess you meant "foo"?
>
> Yes, sorry.
>
>> Maybe we can riff on
>>
>>    extract foo from d
>>
>> ? Though honestly that looks like it would be extracting d.foo, no
>> d['foo'].
>
> Yeah, but that might be useful too :-). How about:
>
> extract key foo from d
> extract attribute foo import d
>
> or
>
> export key foo from d
> export attribute foo import d
>
> As for "import", with both foo and d required to be identifiers.

The versions with "import" in them are DAAP (dead-as-a-parrot).  No 
point in even talking about them.

--
~Ethan~


More information about the Python-ideas mailing list