Wofür wird das Python-Schlüsselwort "with" verwendet? [Duplikat]
Diese Frage hat hier bereits eine Antwort:
Wofür wurde die Python-With-Anweisung entwickelt? 10 AntwortenWofür wird das Python-Schlüsselwort "with" verwendet?
Beispiel von:http://docs.python.org/tutorial/inputoutput.html
>>> with open('/tmp/workfile', 'r') as f:
... read_data = f.read()
>>> f.closed
True