Eliminate "extra" variable

Discussion in 'Python' started by Igor Korot, Dec 6, 2013.

  1. Igor Korot

    Igor Korot Guest

    Hi, ALL,
    I have following code:

    def MyFunc(self, originalData):
    data = {}
    dateStrs = []
    for i in xrange(0, len(originalData)):
    dateStr, freq, source = originalData
    data[str(dateStr)] = {source: freq}
    dateStrs.append(dateStr)
    for i in xrange(0, len(dateStrs) - 1):
    currDateStr = str(dateStrs)
    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.
    Igor Korot, Dec 6, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Otten

    Re: Eliminate "extra" variable

    Peter Otten, Dec 8, 2013, in forum: Python
    Replies:
    0
    Views:
    82
    Peter Otten
    Dec 8, 2013
  2. Tim Chase

    Re: Eliminate "extra" variable

    Tim Chase, Dec 8, 2013, in forum: Python
    Replies:
    0
    Views:
    70
    Tim Chase
    Dec 8, 2013
  3. Tim Chase

    Re: Eliminate "extra" variable

    Tim Chase, Dec 8, 2013, in forum: Python
    Replies:
    0
    Views:
    75
    Tim Chase
    Dec 8, 2013
  4. Mark Lawrence

    Re: Eliminate "extra" variable

    Mark Lawrence, Dec 8, 2013, in forum: Python
    Replies:
    14
    Views:
    128
    Igor Korot
    Dec 16, 2013
  5. Tim Chase

    Re: Eliminate "extra" variable

    Tim Chase, Dec 8, 2013, in forum: Python
    Replies:
    0
    Views:
    62
    Tim Chase
    Dec 8, 2013
Loading...

Share This Page