# HG changeset patch # User Greg Malcolm # Date 1322798178 18000 # Thu Dec 01 22:56:18 2011 -0500 # Node ID 145b2751480de6f77e21a1b87e3472bb89dfa1c4 # Parent 08a266bcf3291ad77ec57d1251d993f46c359dac Merged change by namrsal from github: 'Improved formatting.' diff --git a/python 2/koans/about_iteration.py b/python 2/koans/about_iteration.py --- a/python 2/koans/about_iteration.py +++ b/python 2/koans/about_iteration.py @@ -40,7 +40,8 @@ self.assertEqual(__, mapped_seq) def test_filter_selects_certain_items_from_a_list(self): - def is_even(item): return (item % 2) == 0 + def is_even(item): + return (item % 2) == 0 seq = [1, 2, 3, 4, 5, 6] @@ -48,7 +49,8 @@ self.assertEqual(__, even_numbers) def test_just_return_first_item_found(self): - def is_big_name(item): return len(item) > 4 + def is_big_name(item): + return len(item) > 4 names = ["Jim", "Bill", "Clarence", "Doug", "Eli"] @@ -70,7 +72,7 @@ def multiply(self, accum, item): return accum * item - def test_reduce_will_blow_your_mind(self): + def test_reduce_will_blow_your_mind(self): result = reduce(self.add, [2, 3, 4]) self.assertEqual(__, result) @@ -82,7 +84,7 @@ # ------------------------------------------------------------------ - def test_creating_lists_with_list_comprehensions(self): + def test_creating_lists_with_list_comprehensions(self): feast = ['lambs', 'sloths', 'orangutans', 'breakfast cereals', 'fruit bats'] comprehension = [delicacy.capitalize() for delicacy in feast] @@ -107,7 +109,8 @@ # Files act like a collection of lines file = open("example_file.txt") - def make_upcase(line) : return line.strip().upper() + def make_upcase(line): + return line.strip().upper() upcase_lines = map(make_upcase, file.readlines()) self.assertEqual(__, list(upcase_lines)) @@ -116,4 +119,5 @@ finally: # Arg, this is ugly. # We will figure out how to fix this later. - if file: file.close() + if file: + file.close() diff --git a/python 3/koans/about_iteration.py b/python 3/koans/about_iteration.py --- a/python 3/koans/about_iteration.py +++ b/python 3/koans/about_iteration.py @@ -53,7 +53,8 @@ # python 3. In python 2 map() would give you a list. def test_filter_selects_certain_items_from_a_list(self): - def is_even(item): return (item % 2) == 0 + def is_even(item): + return (item % 2) == 0 seq = [1, 2, 3, 4, 5, 6] even_numbers = list() @@ -64,7 +65,8 @@ self.assertEqual(__, even_numbers) def test_just_return_first_item_found(self): - def is_big_name(item): return len(item) > 4 + def is_big_name(item): + return len(item) > 4 names = ["Jim", "Bill", "Clarence", "Doug", "Eli"] name = None @@ -130,7 +132,8 @@ # Files act like a collection of lines file = open("example_file.txt") - def make_upcase(line) : return line.strip().upper() + def make_upcase(line): + return line.strip().upper() upcase_lines = map(make_upcase, file.readlines()) self.assertEqual(__, list(upcase_lines)) @@ -139,4 +142,5 @@ finally: # Arg, this is ugly. # We will figure out how to fix this later. - if file: file.close() + if file: + file.close() \ No newline at end of file