[Python-ideas] Unpacking a dict
steve at pearwood.info
Thu May 26 13:40:17 EDT 2016
On Thu, May 26, 2016 at 06:50:12PM +0200, Sven R. Kunze wrote:
> So far, all proposals which deviate from Michael's one are just
> "optimizations in terms of characters". The only one I would find not
> necessarily too restrictive were:
> 'a': s1, 'b': s2, 'c': s3 = mapping # no braces :)
> That looks quite good to me. What do you think?
I think that if you submitted code to me with keys 'a', 'b', 'c' and
variables s1, s2, s3, I'd probably reject it and tell you to use
descriptive, meaningful keys and names.
I wish people would stop giving toy examples as examples of how nice the
syntax looks, and instead try to use it with descriptive names taken
from real code. I believe that, by far the majority of the time, you
will be repeating the same names twice, and likely exceeding most
reasonable line lengths:
'referer': referer, 'useragent': useragent, 'use_proxy': use_proxy, 'follow_links': follow_links, 'clobber': clobber, 'timeout': timeout = mapping
Still think it looks quite good? If you do, that's your right, of
course, it's a matter of personal taste. But using toy examples with one
or two letter variable names is not a fair or realistic test of what it
will be like to use this syntax in real code.
More information about the Python-ideas