We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents a0b4957 + 367ff33 commit 9f78b72Copy full SHA for 9f78b72
check_file.py
@@ -4,7 +4,7 @@
4
# Last Modified :
5
# Version : 1.0
6
7
-# Modifications :
+# Modifications : with statement added to ensure correct file closure
8
9
# Description : Check a file exists and that we can read the file
10
@@ -14,7 +14,8 @@
14
# Readfile Functions which open the file that is passed to the script
15
16
def readfile(filename):
17
- line = open(filename, 'r').read()
+ with open(filename, 'r') as f: # Ensure file is correctly closed under all circumstances
18
+ line = f.read()
19
print line
20
21
def main():
0 commit comments