Skip to content

Commit af143bf

Browse files
author
Lars Wiegman
committed
Reformatted single-line functions to multi-line function to improve readability.
1 parent 68341ed commit af143bf

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

python 2/koans/about_iteration.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,17 @@ def test_map_transforms_elements_of_a_list(self):
4040
self.assertEqual(__, mapped_seq)
4141

4242
def test_filter_selects_certain_items_from_a_list(self):
43-
def is_even(item): return (item % 2) == 0
43+
def is_even(item):
44+
return (item % 2) == 0
4445

4546
seq = [1, 2, 3, 4, 5, 6]
4647

4748
even_numbers = filter(is_even, seq)
4849
self.assertEqual(__, even_numbers)
4950

5051
def test_just_return_first_item_found(self):
51-
def is_big_name(item): return len(item) > 4
52+
def is_big_name(item):
53+
return len(item) > 4
5254

5355
names = ["Jim", "Bill", "Clarence", "Doug", "Eli"]
5456

@@ -70,7 +72,7 @@ def add(self, accum, item):
7072
def multiply(self, accum, item):
7173
return accum * item
7274

73-
def test_reduce_will_blow_your_mind(self):
75+
def test_reduce_will_blow_your_mind(self):
7476
result = reduce(self.add, [2, 3, 4])
7577
self.assertEqual(__, result)
7678

@@ -82,7 +84,7 @@ def test_reduce_will_blow_your_mind(self):
8284

8385
# ------------------------------------------------------------------
8486

85-
def test_creating_lists_with_list_comprehensions(self):
87+
def test_creating_lists_with_list_comprehensions(self):
8688
feast = ['lambs', 'sloths', 'orangutans', 'breakfast cereals', 'fruit bats']
8789

8890
comprehension = [delicacy.capitalize() for delicacy in feast]
@@ -107,7 +109,8 @@ def test_all_iteration_methods_work_on_any_sequence_not_just_lists(self):
107109
# Files act like a collection of lines
108110
file = open("example_file.txt")
109111

110-
def make_upcase(line) : return line.strip().upper()
112+
def make_upcase(line) :
113+
return line.strip().upper()
111114
upcase_lines = map(make_upcase, file.readlines())
112115
self.assertEqual(__, list(upcase_lines))
113116

@@ -116,4 +119,5 @@ def make_upcase(line) : return line.strip().upper()
116119
finally:
117120
# Arg, this is ugly.
118121
# We will figure out how to fix this later.
119-
if file: file.close()
122+
if file:
123+
file.close()

0 commit comments

Comments
 (0)