[Python-ideas] Unpacking a dict

Nikolaus Rath Nikolaus at rath.org
Mon May 30 11:07:48 EDT 2016

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


export key foo from d
export attribute foo import d

As for "import", with both foo and d required to be identifiers.


GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             »Time flies like an arrow, fruit flies like a Banana.«

More information about the Python-ideas mailing list