Skip to content

Commit d207051

Browse files
committed
Some small pep8 corrections.
1 parent 02a45af commit d207051

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

3-tier.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4+
45
class Data(object):
56

67
products = {
7-
'milk': { 'price': 1.50, 'quantity': 10 },
8-
'eggs': { 'price': 0.20, 'quantity': 100 },
9-
'cheese': { 'price': 2.00, 'quantity': 10 }
8+
'milk': {'price': 1.50, 'quantity': 10},
9+
'eggs': {'price': 0.20, 'quantity': 100},
10+
'cheese': {'price': 2.00, 'quantity': 10}
1011
}
1112

1213

@@ -37,8 +38,8 @@ def get_product_information(self, product):
3738
product_info = self.business_logic.product_information(product)
3839
if product_info is not None:
3940
print('PRODUCT INFORMATION:')
40-
print('Name: %s, Price: %.2f, Quantity: %d\n' % \
41-
(product.title(), product_info.get('price', 0), \
41+
print('Name: %s, Price: %.2f, Quantity: %d\n' %
42+
(product.title(), product_info.get('price', 0),
4243
product_info.get('quantity', 0)))
4344
else:
4445
print('That product "%s" does not exist in the records' % product)

mvc.py

+16-15
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,54 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
3-
3+
4+
45
class Model(object):
5-
6+
67
products = {
7-
'milk': { 'price': 1.50, 'quantity': 10 },
8-
'eggs': { 'price': 0.20, 'quantity': 100 },
9-
'cheese': { 'price': 2.00, 'quantity': 10 }
8+
'milk': {'price': 1.50, 'quantity': 10},
9+
'eggs': {'price': 0.20, 'quantity': 100},
10+
'cheese': {'price': 2.00, 'quantity': 10}
1011
}
1112

1213

1314
class View(object):
14-
15+
1516
def product_list(self, product_list):
1617
print('PRODUCT LIST:')
1718
for product in product_list:
1819
print(product)
1920
print('')
20-
21+
2122
def product_information(self, product, product_info):
2223
print('PRODUCT INFORMATION:')
23-
print('Name: %s, Price: %.2f, Quantity: %d\n' % \
24-
(product.title(), product_info.get('price', 0), \
24+
print('Name: %s, Price: %.2f, Quantity: %d\n' %
25+
(product.title(), product_info.get('price', 0),
2526
product_info.get('quantity', 0)))
2627

2728
def product_not_found(self, product):
2829
print('That product "%s" does not exist in the records' % product)
2930

3031

3132
class Controller(object):
32-
33+
3334
def __init__(self):
3435
self.model = Model()
3536
self.view = View()
36-
37+
3738
def get_product_list(self):
3839
product_list = self.model.products.keys()
3940
self.view.product_list(product_list)
40-
41+
4142
def get_product_information(self, product):
4243
product_info = self.model.products.get(product, None)
4344
if product_info is not None:
4445
self.view.product_information(product, product_info)
4546
else:
4647
self.view.product_not_found(product)
47-
48-
48+
49+
4950
if __name__ == '__main__':
50-
51+
5152
controller = Controller()
5253
controller.get_product_list()
5354
controller.get_product_information('cheese')

0 commit comments

Comments
 (0)