Skip to content

Commit 4007ac7

Browse files
committed
Minor pep8 correction of the docstring.
1 parent 40a7afc commit 4007ac7

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

template.py

+31-31
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,57 @@
1-
"""http://ginstrom.com/scribbles/2007/10/08/design-patterns-python-style/"""
1+
"""http://ginstrom.com/scribbles/2007/10/08/design-patterns-python-style/
22
3-
"""An example of the Template pattern in Python"""
3+
An example of the Template pattern in Python"""
44

55
ingredients = "spam eggs apple"
66
line = '-' * 10
77

88

99
# Skeletons
10-
def iter_elements(getter, action):
11-
"""Template skeleton that iterates items"""
12-
for element in getter():
13-
action(element)
14-
print(line)
10+
def iter_elements(getter, action):
11+
"""Template skeleton that iterates items"""
12+
for element in getter():
13+
action(element)
14+
print(line)
1515

1616

1717
def rev_elements(getter, action):
18-
"""Template skeleton that iterates items in reverse order"""
19-
for element in getter()[::-1]:
20-
action(element)
21-
print(line)
18+
"""Template skeleton that iterates items in reverse order"""
19+
for element in getter()[::-1]:
20+
action(element)
21+
print(line)
2222

2323

2424
# Getters
25-
def get_list():
26-
return ingredients.split()
25+
def get_list():
26+
return ingredients.split()
2727

2828

2929
def get_lists():
30-
return [list(x) for x in ingredients.split()]
30+
return [list(x) for x in ingredients.split()]
3131

3232

3333
# Actions
34-
def print_item(item):
35-
print(item)
34+
def print_item(item):
35+
print(item)
3636

3737

3838
def reverse_item(item):
39-
print(item[::-1])
39+
print(item[::-1])
4040

4141

4242
# Makes templates
43-
def make_template(skeleton, getter, action):
44-
"""Instantiate a template method with getter and action"""
45-
def template():
46-
skeleton(getter, action)
47-
return template
48-
49-
# Create our template functions
50-
templates = [make_template(s, g, a)
51-
for g in (get_list, get_lists)
52-
for a in (print_item, reverse_item)
53-
for s in (iter_elements, rev_elements)]
54-
55-
# Execute them
56-
for template in templates:
43+
def make_template(skeleton, getter, action):
44+
"""Instantiate a template method with getter and action"""
45+
def template():
46+
skeleton(getter, action)
47+
return template
48+
49+
# Create our template functions
50+
templates = [make_template(s, g, a)
51+
for g in (get_list, get_lists)
52+
for a in (print_item, reverse_item)
53+
for s in (iter_elements, rev_elements)]
54+
55+
# Execute them
56+
for template in templates:
5757
template()

0 commit comments

Comments
 (0)