Here's one argument why sequence unpacking is more important than dict
unpacking.

Without sequence unpacking, you have a long sequence, to get at a specific
item you'd need to use indexing, where you often end up having to remember
the indices for each type of information. Say you have points of the form
(x, y, z, t), to get at the t coordinate you'd have to write p[3]. With
sequence unpacking you can write

  x, y, z, t = p

and then you can use the individual variables in the subsequent code.

However if your point had the form {'x': x, 'y': y, 'z': z, 't': t}, you
could just write p['t']. This is much more mnemonic than p[3].

All the rest follows -- after a while extended forms of iterable unpacking
start making sense. But for dicts the use case is just much less common.

(If you're doing a lot of JSON you might have a different view on that. You
should probably use some kind of schema-guided parser though.)

-- 
--Guido van Rossum (python.org/~guido)
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to