Skip to content

Commit a79491d

Browse files
committed
Update Factory.py for Python 3.4.1
"The print statement has been replaced with a print() function, with keyword arguments to replace most of the special syntax of the old print statement (PEP 3105)"
1 parent c83fd65 commit a79491d

File tree

1 file changed

+1
-38
lines changed

1 file changed

+1
-38
lines changed

factory.py

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -29,42 +29,5 @@ def create_pizza(pizza_type):
2929

3030
if __name__ == '__main__':
3131
for pizza_type in ('HamMushroom', 'Deluxe', 'Hawaiian'):
32-
print 'Price of {0} is {1}'.format(pizza_type, PizzaFactory.create_pizza(pizza_type).get_price())
32+
print('Price of {0} is {1}'.format(pizza_type, PizzaFactory.create_pizza(pizza_type).get_price())
3333

34-
35-
# ------------------- Second example -----------------
36-
37-
38-
class JapaneseGetter:
39-
"""A simple localizer a la gettext"""
40-
41-
def __init__(self):
42-
self.trans = dict(dog="犬", cat="猫")
43-
44-
def get(self, msgid):
45-
"""We'll punt if we don't have a translation"""
46-
47-
try:
48-
return unicode(self.trans[msgid], "utf-8")
49-
except KeyError:
50-
return unicode(msgid)
51-
52-
class EnglishGetter:
53-
"""Simply echoes the msg ids"""
54-
def get(self, msgid):
55-
return unicode(msgid)
56-
57-
def get_localizer(language="English"):
58-
"""The factory method"""
59-
60-
languages = dict(English=EnglishGetter,
61-
Japanese=JapaneseGetter)
62-
63-
return languages[language]()
64-
65-
# Create our localizers
66-
e, j = get_localizer("English"), get_localizer("Japanese")
67-
68-
# Localize some text
69-
for msgid in "dog parrot cat".split():
70-
print e.get(msgid), j.get(msgid)

0 commit comments

Comments
 (0)