Coding style.
- Consistently use 'with' with open.
This commit is contained in:
parent
4f2e31482b
commit
ffdf4f3d86
1 changed files with 4 additions and 3 deletions
|
|
@ -265,13 +265,14 @@ class Editor:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def load(self, path):
|
def load(self, path):
|
||||||
self.set_text(open(path).read())
|
with open(path) as file_:
|
||||||
|
self.set_text(file_.read())
|
||||||
self.path = path
|
self.path = path
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
if self.previous_term_code == terminal.CTRL_X:
|
if self.previous_term_code == terminal.CTRL_X:
|
||||||
with open(self.path, "w") as f:
|
with open(self.path, "w") as file_:
|
||||||
f.write(self.text_widget.get_text())
|
file_.write(self.text_widget.get_text())
|
||||||
self.original_text = self.text_widget.actual_text.copy()
|
self.original_text = self.text_widget.actual_text.copy()
|
||||||
|
|
||||||
def backspace(self):
|
def backspace(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue