Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #43641

Re: Process tuple contents on the fly

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@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.022
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'read.': 0.03; 'd[key]': 0.16; 'dict': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'print': 0.22; 'header:User-Agent:1': 0.23; 'header:In-Reply-To:1': 0.27; 'easier': 0.31; 'subject:the': 0.34; 'received:84': 0.35; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'more': 0.64; 'header:Reply-To:1': 0.67; 'results': 0.69; 'reply-to:no real name:2**0': 0.71; 'reply-to:addr:python.org': 0.84
X-CM-Score 0.00
X-CNFS-Analysis v=2.1 cv=N54QSQNB c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=7AxPfEIvyrUA:10 a=UDOsjbjU2MkA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=IihjgFFVbeMA:10 a=xJ7RIdwm523H562vbHMA:9 a=wPNLvfGTeEIA:10
X-AUTH mrabarnett:2500
Date Mon, 15 Apr 2013 20:29:47 +0100
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130328 Thunderbird/17.0.5
MIME-Version 1.0
To python-list@python.org
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>
In-Reply-To <CAK3ADtdGH-J0QtHC85gZQX0mF-BKyAmM-neYevZ-YEZtK_hhQw@mail.gmail.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To python-list@python.org
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.645.1366054372.3114.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1366054372 news.xs4all.nl 2635 [2001:888:2000:d::a6]:43017
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:43641

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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