Last active
December 12, 2015 13:39
-
-
Save chirag-v/4780243 to your computer and use it in GitHub Desktop.
reading file old try/finally way
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
f = open('/home/user/acetylene.xyz') | |
while True: | |
line = f.readline() | |
if len(line) == 0: | |
break | |
print(line, end=' ') | |
finally: | |
f.close() | |
print('file is closed now!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment