Skip to content

Instantly share code, notes, and snippets.

@ejcer
Created October 7, 2016 15:52
Show Gist options
  • Save ejcer/9614afecdb0acf77a86097dc77d88bc3 to your computer and use it in GitHub Desktop.
Save ejcer/9614afecdb0acf77a86097dc77d88bc3 to your computer and use it in GitHub Desktop.

Revisions

  1. @eddytbd eddytbd created this gist Oct 7, 2016.
    13 changes: 13 additions & 0 deletions idioms.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    #unpythonic code in idiom_tests_copy.py:
    result = []
    for i in range(10):
    s = i ** 2
    result.append(s)
    print(sum(result))




    #pythonic code that I was attempting to transform idiom_tests_copy.py into:
    result = [i**2 for i in range(10)]
    print(sum(result))