[Python-ideas] Unpacking a dict

Sven R. Kunze srkunze at mail.de
Thu May 26 12:41:42 EDT 2016


On 26.05.2016 01:25, Ethan Furman wrote:
> We already have that situation:
>
>   some_var = [1, 2]
>   a = some_var[0]
>   b = some_var[1]
>
> is exactly the same as
>
>   a, b = some_var
>
> and the visual indicators (the integers, the item access) are nowhere 
> to be seen.

Good point. However, don't you think this case is different?


As a human (at least the ones I know) can easily relate position and 
index number. So, 1 is first, 2 is second and so on. That's pretty 
straightforward. So, the item access is quite naturally mapped.


With keys of a dictionary it is less clear. I prefer the explicit key 
variant over some implicitly working one. Maybe there will come up a 
better argument for or against this. We will see.


Best,
Sven


More information about the Python-ideas mailing list