[Python-ideas] Short form for keyword arguments and dicts

Joshua Landau joshua.landau.ws at gmail.com
Sat Jun 29 21:51:37 CEST 2013


On 29 June 2013 18:19, MRAB <python at mrabarnett.plus.com> wrote:
> On 30/06/13 02:20, Joshua Landau wrote:
>> I haven't been able to find a really good syntax from this, but something
>> like:
>>
>> 1) foo(a, b, **(key1, key2 from locals()))
>>
>> 2) {**(key1, key2 from locals())}
>>
>> 3) import key1, key2 from {"key1": 123, "key2": 345}
>>
>> etc.
>>
> You could just add a method to dict:
>
> foo(a, b, **locals().subdict(["key1", "key2"]))

Only for (1), and (2) once http://bugs.python.org/issue2292 is in.

Again, though, I don't really care about the syntax as it's not the
point I was making.


More information about the Python-ideas mailing list