[Python-ideas] Enhancing dict.values
Chris Barker
chris.barker at noaa.gov
Fri May 27 12:36:57 EDT 2016
On Fri, May 27, 2016 at 9:17 AM, Steven D'Aprano <steve at pearwood.info>
wrote:
> # apologies for breaking my own rule about realistic names
> fee, fi, fo, fum = mydict.getmany('fee', 'fi', 'fo', 'fum')
>
so how again is the much better than:
> Isn't this the status quo?
> a, b, c = [mapping[k] for k in ('a', 'b', 'c')]
the objection to that was that it gets ugly when you've got longer, more
realistic names (and maybe more of them.)
fee, fi, fo, fum = [mapping[k] for k in ('fee', 'fi', 'fo', 'fum')]
only a little more typing, and in both cases, you need to specify the names
twice.
(of course, they don't need to be the same names...)
-CHB
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160527/e9445470/attachment.html>
More information about the Python-ideas
mailing list