News for hackers. Stuff that matters.
Re:Python Idioms [pdf] by kerpal on Thursday January 30, 2014 @12:38PM (#7151957)
Thanks for this write up. I didn't know about enumerate. I never thought of swapping variables as in example 4 either.

I noticed one small mistake in section 9:

  d[keys] = values[i] 
Should be:

  d[key] = values[i]
Re:Python Idioms [pdf] by aaren on Thursday January 30, 2014 @07:30PM (#7154419)
For a good few months I was doing

    for i in range(len(input_list)):
        v = input_list[i]
        ...do something with v and i...
enumerate is much nicer!

    for i, v in enumerate(input_list):
        ...