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


Groups > comp.lang.python > #61190 > unrolled thread

Eliminate "extra" variable

Started byIgor Korot <ikorot01@gmail.com>
First post2013-12-06 11:37 -0800
Last post2013-12-06 11:37 -0800
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

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

#61190 — Eliminate "extra" variable

FromIgor Korot <ikorot01@gmail.com>
Date2013-12-06 11:37 -0800
SubjectEliminate "extra" variable
Message-ID<mailman.3670.1386371396.18130.python-list@python.org>
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.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web