Skip to content
This repository was archived by the owner on Nov 4, 2022. It is now read-only.

Commit 004e1a7

Browse files
committed
The with part is better because it close the file afterwards.
1 parent 1ea2dd6 commit 004e1a7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

env_check.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@
1414
conffile = 'env_check.conf' # Set the variable conffile
1515
conffilename = os.path.join(confdir, conffile) # Set the variable conffilename by joining confdir and conffile together
1616

17+
# with open(conffilename) as f:
18+
# for line in f:
19+
# print line
20+
1721
for env_check in open(conffilename): # Open the config file and read all the settings
1822
env_check = env_check.strip() # Set the variable as itsself, but strip the extra text out
1923
print '[{}]'.format(env_check) # Format the Output to be in Square Brackets
2024
newenv = os.getenv(env_check) # Set the variable newenv to get the settings from the OS what is currently set for the settings out the configfile
21-
25+
2226
if newenv is None: # If it doesn't exist
2327
print env_check, 'is not set' # Print it is not set
2428
else: # Else if it does exist

0 commit comments

Comments
 (0)