Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.024 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'happen,': 0.09; 'iterate': 0.09; 'subject:extra': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'docstring': 0.16; 'output?': 0.16; 'roy': 0.16; 'subject:variable': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'input': 0.22; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'lets': 0.24; '---': 0.24; 'cc:2**0': 0.24; 'source': 0.25; '>': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'dec': 0.30; 'skip:& 60': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'directly,': 0.31; 'supposed': 0.32; 'url:python': 0.33; 'fri,': 0.33; 'could': 0.34; 'agree': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'url:listinfo': 0.36; 'url:org': 0.36; 'list': 0.37; 'pm,': 0.38; 'explain': 0.39; 'subject:" ': 0.39; 'sure': 0.39; 'url:mail': 0.40; 'even': 0.60; 'complete': 0.62; 'more': 0.64; 'smith': 0.68; 'article': 0.77; 'joel': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=WhM3EtuFToYfR8F+mXhjovMTRRN5NrBRHDKZZMIoz9Q=; b=be2UyeC0jOlITMCfWNS9qEpH9zufBfB5rLN5jhj9nZXZuTEoYcNFsojbfkJ3Z5kZ48 ov5BHEKJPZCd6Aq+mx/VJuEO90DT2Pgj5h7cax0w9+d7j1rCQHVbmydbUN0YHsIwGuhu mvThluaC4UGKQPYNN6EzFx93diAymhGrW9XvbQbWlNEv/eI4XS1I1ZgmGwz3uFLHt2/R Gz9ErDbvv58oMw4+nkZlPYIRGYO3Um2ucK9Z6euLtJ87L4GFKXSJnWwSsI+WqdJEkAwC 8vbF0Cf3dql/tT46k+NEBSiAJO2OYlEv+qMJYRrwS6nVPwTL6YfFG0IW3t10bdevwGxC V6xQ== MIME-Version: 1.0 X-Received: by 10.220.122.129 with SMTP id l1mr2736279vcr.48.1386376348500; Fri, 06 Dec 2013 16:32:28 -0800 (PST) In-Reply-To: References: Date: Fri, 6 Dec 2013 19:32:28 -0500 Subject: Re: Eliminate "extra" variable From: Joel Goldstick To: Roy Smith Content-Type: multipart/alternative; boundary=089e013a15f2c7341804ece6e57f Cc: "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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 80 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1386376351 news.xs4all.nl 2922 [2001:888:2000:d::a6]:59416 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:61203 --089e013a15f2c7341804ece6e57f Content-Type: text/plain; charset=UTF-8 On Fri, Dec 6, 2013 at 7:16 PM, Roy Smith wrote: > In article , > Joel Goldstick wrote: > > > Python lets you iterate over a list directly, so : > > > > for d in originalData: > > dateStr, freq, source = d > > data[source] = freq > > I would make it even simpler: > > > for dateStr, freq, source in originalData: > > data[source] = freq > +1 --- I agree To the OP: Could you add a docstring to your function to explain what is supposed to happen, describe the input and output? If you do that I'm sure you could get some more complete help with your code. > -- > https://mail.python.org/mailman/listinfo/python-list > -- Joel Goldstick http://joelgoldstick.com --089e013a15f2c7341804ece6e57f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On F= ri, Dec 6, 2013 at 7:16 PM, Roy Smith <roy@panix.com> wrote:
=
In article <mailman.3672.1386373120.18130.python-list@python.org>,
=C2=A0Joel Goldstick <joel.goldstick@gmail.com> wrote:

> Python lets you iterate over a list directly, so :
>
> =C2=A0 =C2=A0 for d in originalData:
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 dateStr, freq, source =3D d
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 data[source] =3D freq

I would make it even simpler:

> =C2=A0 =C2=A0 for dateStr, freq, source in originalData:
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 data[source] =3D freq
<= div>

+1 --- I agree

To the OP:

<= /div>
Could you add a docstring to your function to explain what is sup= posed to happen, describe the input and output?=C2=A0 If you do that I'= m sure you could get some more complete help with your code.
--
https://mail.python.org/mailman/listinfo/python-list



--
--089e013a15f2c7341804ece6e57f--