Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #43641
| Date | 2013-04-15 20:29 +0100 |
|---|---|
| From | MRAB <python@mrabarnett.plus.com> |
| Subject | Re: Process tuple contents on the fly |
| References | <f51058c3-0e36-429c-85d9-365be82b548f@googlegroups.com> <20130415135013.58430065@bigbox.christie.dr> <CAK3ADtdGH-J0QtHC85gZQX0mF-BKyAmM-neYevZ-YEZtK_hhQw@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.645.1366054372.3114.python-list@python.org> (permalink) |
On 15/04/2013 20:05, Barrett Lewis wrote:
>
>
>
> d = {}
> for key, d[key] in (("this",18), ("that",17), ("other",38)):
> print key
> do_something(d)
>
>
> Why not use a dict comprehension?
> d = {k:v for k,v in (("this",18), ("that",17), ("other",38))}
>
> I feel this is more straightforward and easier to read. the results are
> the same however.
>
Why use a dict comprehension? :-)
d = dict((("this",18), ("that",17), ("other",38))}
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Process tuple contents on the fly Gnarlodious <gnarlodious@gmail.com> - 2013-04-15 11:25 -0700
Re: Process tuple contents on the fly Tim Chase <python.list@tim.thechases.com> - 2013-04-15 13:50 -0500
Re: Process tuple contents on the fly Barrett Lewis <musikal.fusion@gmail.com> - 2013-04-15 12:05 -0700
Re: Process tuple contents on the fly Peter Otten <__peter__@web.de> - 2013-04-15 21:07 +0200
Re: Process tuple contents on the fly Tim Chase <python.list@tim.thechases.com> - 2013-04-15 14:10 -0500
Re: Process tuple contents on the fly Barrett Lewis <musikal.fusion@gmail.com> - 2013-04-15 12:16 -0700
Re: Process tuple contents on the fly MRAB <python@mrabarnett.plus.com> - 2013-04-15 20:29 +0100
Re: Process tuple contents on the fly Tobiah <toby@tobiah.org> - 2013-04-15 13:35 -0700
Re: Process tuple contents on the fly Michael Torrie <torriem@gmail.com> - 2013-04-15 15:16 -0600
Re: Process tuple contents on the fly Gnarlodious <gnarlodious@gmail.com> - 2013-04-15 16:46 -0700
csiph-web