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 f27e91e commit 4d85fccCopy full SHA for 4d85fcc
1 file changed
Doc/tutorial/stdlib2.rst
@@ -178,14 +178,13 @@ tasks in background while the main program continues to run::
178
179
class AsyncZip(threading.Thread):
180
def __init__(self, infile, outfile):
181
- threading.Thread.__init__(self)
+ super().__init__()
182
self.infile = infile
183
self.outfile = outfile
184
185
def run(self):
186
- f = zipfile.ZipFile(self.outfile, 'w', zipfile.ZIP_DEFLATED)
187
- f.write(self.infile)
188
- f.close()
+ with zipfile.ZipFile(self.outfile, 'w', zipfile.ZIP_DEFLATED) as f:
+ f.write(self.infile)
189
print('Finished background zip of:', self.infile)
190
191
background = AsyncZip('mydata.txt', 'myarchive.zip')
0 commit comments