Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.017 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'read.': 0.03; 'cc:addr :python-list': 0.11; 'd[key]': 0.16; 'dict': 0.16; 'to:addr:python.list': 0.16; 'to:addr:tim.thechases.com': 0.16; 'to:name:tim chase': 0.16; 'cc:addr:gmail.com': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**1': 0.23; 'skip:\xa0 20': 0.24; 'header:In-Reply-To:1': 0.27; 'message- id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; 'easier': 0.31; 'subject:the': 0.34; 'received:google.com': 0.35; '8bit%:4': 0.38; 'more': 0.64; 'results': 0.69; 'received:mail- ob0-x22f.google.com': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=vw/AC8Qg+fOiY6uwA7wXKdt1d+zrJIu0zocAgqB1htw=; b=DDw4fvmIJ71cP2EsxJiDVFNR1Iq0o3dOsWv8S8Gc2ucEf4OVwtMagWztGatJ7NoB9m FFo5XyFS5Rgsb2ZPrz6lMMiEw7e+7G1rxFuwLHMcgyoM3Khb6pdI6/iAqcuT6ERLD3n3 fa9p401qAfCjTUFMXhC8Hp4Fzrsgb27xvnjOGNrZag3PQGXe/xpquP7156bqrVVj8b84 a03Ic+T5ZsnKiR2/8Fw3QBVhPDLCkZ/9dgPFapPn1/d0PFlz/jTIE6SI3v/v/3ahVlb4 f6lsq3LbP/SG+nFJiU6oxSvzeKMWB+NKuhX1QV48fVZAxCMmZkvowySVZkCX6c6Q54Ow brJA== X-Received: by 10.182.164.8 with SMTP id ym8mr7957575obb.68.1366052734328; Mon, 15 Apr 2013 12:05:34 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20130415135013.58430065@bigbox.christie.dr> References: <20130415135013.58430065@bigbox.christie.dr> From: Barrett Lewis Date: Mon, 15 Apr 2013 12:05:04 -0700 Subject: Re: Process tuple contents on the fly To: Tim Chase Content-Type: multipart/alternative; boundary=e89a8f646a07f9b74404da6aefd6 Cc: Python Mailing List , Gnarlodious X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1366052737 news.xs4all.nl 2650 [2001:888:2000:d::a6]:52364 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:43636 --e89a8f646a07f9b74404da6aefd6 Content-Type: text/plain; charset=ISO-8859-1 > 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. --e89a8f646a07f9b74404da6aefd6 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable



=A0 d =3D {}
=A0 for key, d[key] in (("this",18), ("that",17), (&quo= t;other",38)):
=A0 =A0 print key
=A0 =A0 do_something(d)

Why not u= se a dict comprehension?
d =3D {k:v for k,v in =A0(("t= his",18), ("that",17), ("other",38))}

I feel this is more straightforward and easier to read= . the results are the same however.
--e89a8f646a07f9b74404da6aefd6--