[Python-ideas] Unpacking a dict

tritium-list at sdamon.com tritium-list at sdamon.com
Thu May 26 00:39:02 EDT 2016

I am -1 on the whole idea.  What is either asking for the identifier being
assigned to having semantic meaning in the language, something we do not
have anywhere else.  (yes, we have special names, but the language does not
actually care about what object you assign to the special name, and the name
itself does not change the behavior of the assignment.)  OR is totally
redundant to something we can already do:

a, b, c, *r = mapping.values()

-----Original Message-----
From: Python-ideas
[mailto:python-ideas-bounces+tritium-list=sdamon.com at python.org] On Behalf
Of Ethan Furman
Sent: Wednesday, May 25, 2016 2:47 PM
To: python-ideas at python.org
Subject: Re: [Python-ideas] Unpacking a dict

On 05/25/2016 11:42 AM, Steven D'Aprano wrote:
> On Wed, May 25, 2016 at 01:11:35PM +0000, Michael Selik wrote:

>>      py> mapping = {"a": 1, "b": 2, "c": 3}
>>      py> {"a": x, "b": y, "c": z} = mapping
>>      py> x, y, z
>>      (1, 2, 3)
> I think that is too verbose and visually baffling. I'd rather see
> something less general and (in my opinion) more useful:
> a, b, c = **mapping
> being equivalent to:
> a = mapping['a']
> b = mapping['b']
> c = mapping['c']


Simplest, easiest to grok, probably solves 95+% of the use-cases.

Python-ideas mailing list
Python-ideas at python.org
Code of Conduct: http://python.org/psf/codeofconduct/

More information about the Python-ideas mailing list