[Python-ideas] Unpacking a dict

Nikolaus Rath Nikolaus at rath.org
Fri May 27 14:29:16 EDT 2016

On May 27 2016, Brendan Barnwell <brenbarn-OJtuk2o/0Ank1uMJSBkQmQ at public.gmane.org> wrote:
> On 2016-05-27 08:09, Nikolaus Rath wrote:
>> Very true. But as someone else already said (I can't find the email
>> right now), we have a different construct that everyone is familiar with
>> and that's easily adapted for this situation:
>> from dict context import active_id, active_ids, active_model
>> or more general:
>> "from dict"  <expr> "import" <identifier list>
>> Everyone knows that "from .. import .." modifies the local namespace. We
>> just have to extend it to work not just on modules, but also on
>> dictionaries.
> 	One problem with this is that currently "from" doesn't operate
> on names or objects.  It operates on module paths.  You can't do this:
> import somepackage as othername
> from othername import something
> 	(You'll get "No module named othername".)
> 	If we change this

I'm not proposing to change this. I'm proposing to add a new "from dict
<foo> import <bar>" statement that provides the new functionality.


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