Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e8eabe7 commit e4f6a80Copy full SHA for e4f6a80
1 file changed
Doc/library/atexit.rst
@@ -61,14 +61,11 @@ from a file when it is imported and save the counter's updated value
61
automatically when the program terminates without relying on the application
62
making an explicit call into this module at termination. ::
63
64
- infile = open("/tmp/counter")
65
try:
66
- _count = int(infile.read())
+ with open("/tmp/counter") as infile:
+ _count = int(infile.read())
67
except IOError:
68
_count = 0
69
- finally:
70
- infile.close()
71
-
72
73
def incrcounter(n):
74
global _count
0 commit comments