Skip to content

Commit 4cf4dc6

Browse files
authored
Final QA (#482)
1 parent 8c4f3e3 commit 4cf4dc6

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

python-magic-methods/reader.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
class TextFileReader:
2-
def __init__(self, file_path):
2+
def __init__(self, file_path, encoding="utf-8"):
33
self.file_path = file_path
4+
self.encoding = encoding
45

56
def __enter__(self):
6-
self.file_obj = open(self.file_path, mode="r")
7+
self.file_obj = open(self.file_path, mode="r", encoding=self.encoding)
78
return self.file_obj
89

910
def __exit__(self, exc_type, exc_val, exc_tb):

python-magic-methods/stack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __iadd__(self, other):
2222
return self
2323

2424
def __iter__(self):
25-
return iter(self.items)
25+
return iter(self.items[::-1])
2626

2727
def __repr__(self):
2828
return f"{type(self).__name__}({self.items!r})"

0 commit comments

Comments
 (0)