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


Groups > comp.lang.python > #61190

Eliminate "extra" variable

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!news.astraweb.com!border2.a.newsrouter.astraweb.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ikorot01@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.026
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'subject:extra': 0.09; 'def': 0.12; '1):': 0.16; 'keys.': 0.16; 'looping': 0.16; 'subject:variable': 0.16; 'all,': 0.19; 'seems': 0.21; 'rid': 0.24; 'source': 0.25; 'code:': 0.26; 'message-id:@mail.gmail.com': 0.30; 'skip:d 20': 0.34; 'received:google.com': 0.35; 'hi,': 0.36; 'list': 0.37; 'thank': 0.38; 'to:addr:python-list': 0.38; 'subject:" ': 0.39; 'to:addr:python.org': 0.39; 'you.': 0.62
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=iuyEjOgg6GYYCFRVBDiC8fAhIkTFkoCLWqk6ilRI3Ek=; b=NwQ2sYBHhO2oDUI0067U1qP+AxA9KjSzWslWXg75IF/wHqIp9hNKZ8jsmDCYJgx/HY zBMLx+pTJTiidAq2RuqL5wSkt4goRFZ9CWv/7scirbIJ5kYCJqqsZ1ZsMZnSaMkE2FYW DDd/vN/zIePy74fjNnos+KQ0s8iJZTPHtcQ1DXn8S1N3PFPT9yy2jciURvmTo3shUogO Kh8cVi5kZWztkPKlfizbYp7q8/L6XLG0Wt+HX+fB1XDqTtPXaPHbNnlHBO4QGZsNUJwu 2M+Fu1AC0yoabTfNJmINOQUFyZWKftZmFDB3pcBQzSLAtraWzq99uxH7T7knbkvF8DLl UU1A==
MIME-Version 1.0
X-Received by 10.220.199.5 with SMTP id eq5mr2938430vcb.16.1386358631199; Fri, 06 Dec 2013 11:37:11 -0800 (PST)
Date Fri, 6 Dec 2013 11:37:11 -0800
Subject Eliminate "extra" variable
From Igor Korot <ikorot01@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-Mailman-Approved-At Sat, 07 Dec 2013 00:09:55 +0100
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 <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3670.1386371396.18130.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1386371396 news.xs4all.nl 2907 [2001:888:2000:d::a6]:50511
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:61190

Show key headers only | View raw


Hi, ALL,
I have following code:

def MyFunc(self, originalData):
     data = {}
     dateStrs = []
     for i in xrange(0, len(originalData)):
           dateStr, freq, source = originalData[i]
           data[str(dateStr)]  = {source: freq}
           dateStrs.append(dateStr)
    for i in xrange(0, len(dateStrs) - 1):
          currDateStr = str(dateStrs[i])
          nextDateStrs = str(dateStrs[i + 1])


It seems very strange that I need the dateStrs list just for the
purpose of looping thru the dictionary keys.
Can I get rid of the "dateStrs" variable?

Thank you.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Eliminate "extra" variable Igor Korot <ikorot01@gmail.com> - 2013-12-06 11:37 -0800

csiph-web