From c4da4bdcb6f5ec215fa85272e4ab180626dcb62d Mon Sep 17 00:00:00 2001 From: Salvo 'LtWorf' Tomaselli Date: Sat, 24 Jun 2017 10:10:52 +0200 Subject: [PATCH] Use with block to open file --- driver.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/driver.py b/driver.py index 22d6b06..ef1dc57 100755 --- a/driver.py +++ b/driver.py @@ -40,10 +40,9 @@ tests_path = 'test/' def readfile(fname): '''Reads a file as string and returns its content''' - fd = open(fname, encoding='utf-8') - expr = fd.read() - fd.close() - return expr + with open(fname, encoding='utf-8') as fd: + expr = fd.read() + return expr def load_relations():