Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #43639
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python.list@tim.thechases.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.007 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'read.': 0.03; 'function,': 0.09; 'cc:addr:python-list': 0.11; '-tkc': 0.16; 'd[key]': 0.16; 'dict': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'pythonic': 0.16; 'wrote:': 0.18; 'result.': 0.19; 'code,': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**1': 0.23; 'expanded': 0.24; 'header:In-Reply-To:1': 0.27; 'easier': 0.31; 'discovery': 0.31; 'subject:the': 0.34; 'but': 0.35; 'charset:us- ascii': 0.36; 'needed': 0.38; 'rather': 0.38; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'results': 0.69; 'received:50.22': 0.84 |
| Date | Mon, 15 Apr 2013 14:10:42 -0500 |
| From | Tim Chase <python.list@tim.thechases.com> |
| To | Barrett Lewis <musikal.fusion@gmail.com> |
| Subject | Re: Process tuple contents on the fly |
| In-Reply-To | <CAK3ADtdGH-J0QtHC85gZQX0mF-BKyAmM-neYevZ-YEZtK_hhQw@mail.gmail.com> |
| References | <f51058c3-0e36-429c-85d9-365be82b548f@googlegroups.com> <20130415135013.58430065@bigbox.christie.dr> <CAK3ADtdGH-J0QtHC85gZQX0mF-BKyAmM-neYevZ-YEZtK_hhQw@mail.gmail.com> |
| X-Mailer | Claws Mail 3.7.6 (GTK+ 2.20.1; x86_64-pc-linux-gnu) |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=US-ASCII |
| Content-Transfer-Encoding | 7bit |
| X-AntiAbuse | This header was added to track abuse, please include it with any abuse report |
| X-AntiAbuse | Primary Hostname - boston.accountservergroup.com |
| X-AntiAbuse | Original Domain - python.org |
| X-AntiAbuse | Originator/Caller UID/GID - [47 12] / [47 12] |
| X-AntiAbuse | Sender Address Domain - tim.thechases.com |
| Cc | Python Mailing List <python-list@python.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.643.1366052947.3114.python-list@python.org> (permalink) |
| Lines | 21 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1366052947 news.xs4all.nl 2640 [2001:888:2000:d::a6]:55731 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:43639 |
Show key headers only | View raw
On 2013-04-15 12: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.
In the particular case I did it in, I needed the incremental results
passed to a function, not just the final result. I don't think this
made it into the final code, rather it was expanded to be more
readable. But the discovery made me feel a disturbance in the
Pythonic force of the universe. :*)
-tkc
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