Skip to content

Commit 37c3a9a

Browse files
committed
Final QA (#525)
1 parent ed0153a commit 37c3a9a

5 files changed

Lines changed: 9 additions & 10 deletions

File tree

python-string-interpolation/article.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ def __str__(self):
1414
def __repr__(self):
1515
return (
1616
f"{type(self).__name__}("
17-
f"title={self.title}, "
18-
f"author={self.author}, "
19-
f"pub_date={self.pub_date})"
17+
f"title={self.title!r}, "
18+
f"author={self.author!r}, "
19+
f"pub_date={self.pub_date!r})"
2020
)
2121

2222

python-string-interpolation/emails.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"""
1313

1414

15-
def display_emails(template, data_file):
16-
with open(data_file) as file:
15+
def display_emails(template, path):
16+
with open(path) as file:
1717
for customer in csv.DictReader(file):
1818
print(template.format(**customer))
1919

python-string-interpolation/format_method.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
print("Hello, {}! Today is {}.".format(name, day))
55

6-
76
numbers = {"one": 1, "two": 2, "three": 3}
87
print("{one}-{two}-{three}".format(**numbers))
98
print("{one}-{two}".format(**numbers))

python-string-interpolation/modulo_operator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55

66
x = 5
77
y = 10
8-
print("The sum of %s and %s is %s." % (x, y, x + y))
8+
print("The sum of %d and %d is %d." % (x, y, x + y))
99

10-
template = "The sum of %s and %s is %s."
10+
template = "The sum of %d and %d is %d."
1111
print(template % (x, y, x + y))
1212

1313
print("Hello, %s!" % "Pythonista")
1414
print("Hello, %s!" % ("Pythonista",))
1515

16-
# print("Interpolating a tuple: %s" % (1, 2, 3))
16+
print("Interpolating a tuple: %s" % (1, 2, 3)) # Raises a TypeError
1717
print("Interpolating a tuple: %s" % ((1, 2, 3),))
1818

1919
jane = {"name": "Jane", "job": "Python Dev"}

python-string-interpolation/template_strings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
print(Template("$greeting, $who!").substitute(greeting="Hello", who="World"))
88

99
print(Template("${amount}USD").substitute(amount="100"))
10-
print(Template("$amountUSD").substitute(amount="100"))
10+
print(Template("$amountUSD").substitute(amount="100")) # Raises a KeyError
1111

1212
greeting = Template("Hello, $name! Today is $day.")
1313
print(greeting.substitute(name="John", day="Friday"))

0 commit comments

Comments
 (0)