Skip to content

Commit

Permalink
Merge pull request geekcomputers#63 from frasercrossman/master
Browse files Browse the repository at this point in the history
Enforce correct file closure
  • Loading branch information
geekcomputers committed Jul 28, 2016
2 parents a0b4957 + 367ff33 commit 9f78b72
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions check_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Last Modified :
# Version : 1.0

# Modifications :
# Modifications : with statement added to ensure correct file closure

# Description : Check a file exists and that we can read the file

Expand All @@ -14,7 +14,8 @@
# Readfile Functions which open the file that is passed to the script

def readfile(filename):
line = open(filename, 'r').read()
with open(filename, 'r') as f: # Ensure file is correctly closed under all circumstances
line = f.read()
print line

def main():
Expand Down

0 comments on commit 9f78b72

Please sign in to comment.