8000 Simplify PdfFileSplitter challenge solution by removing calls to str() · arbi11/python-basics-exercises@2c6d799 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2c6d799

Browse files
committed
Simplify PdfFileSplitter challenge solution by removing calls to str()
1 parent abf7be6 commit 2c6d799

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ch13-interact-with-pdf-files/3-challenge-PdfFileSplitter-class.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class PdfFileSplitter:
1111

1212
def __init__(self, pdf_path):
1313
# Open the PDF file with a new PdfFileReader instance
14-
self.pdf_reader = PdfFileReader(str(pdf_path))
14+
self.pdf_reader = PdfFileReader(pdf_path)
1515
# Initialize the .writer1 and .writer2 attributes to None
1616
self.writer1 = None
1717
self.writer2 = None
@@ -32,10 +32,10 @@ def split(self, breakpoint):
3232
def write(self, filename):
3333
"""Write both PdfFileWriter instances to files"""
3434
# Write the first file to <filename>_1.pdf
35-
with Path(str(filename) + "_1.pdf").open(mode="wb") as output_file:
35+
with Path(filename + "_1.pdf").open(mode="wb") as output_file:
3636
self.writer1.write(output_file)
3737
# Write the second file to <filename>_2.pdf
38-
with Path(str(filename) + "_2.pdf").open(mode="wb") as output_file:
38+
with Path(filename + "_2.pdf").open(mode="wb") as output_file:
3939
self.writer2.write(output_file)
4040

4141

0 commit comments

Comments
 (0)
0