Skip to content

Instantly share code, notes, and snippets.

@DanielSzoska
Created October 9, 2012 07:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanielSzoska/3857192 to your computer and use it in GitHub Desktop.
Save DanielSzoska/3857192 to your computer and use it in GitHub Desktop.
Auszug aus TextPatcher.__init__
with io.open(..) as f:
# do something
pass
# save the type of newlines
self.newlines = f.newlines
with io.open(..) as f:
# do something
pass
# save the type of newlines
self.newlines = f.newlines
@DanielSzoska
Copy link
Author

Hallo Christian,

Ich würde vorsichtshalber das Konstrukt in TextPatcher.__init__.modfified.py verwenden, da ich immer davon ausgehe, daß das Objekt, was durch die with-Anweisung erstellt wird, nach dem Ende des with-Blocks nicht mehr zwingend da sein muß bzw. einen undefinierten Zustand hat. Wie siehst Du das?

@ctismer
Copy link

ctismer commented Oct 9, 2012

Ist unnoetig. file.newlines ist die History der Datei, und die bleibt auch wenn die Datei geschlossen wird. Nur das Dateiobjekt muss noch existieren, und das tut's.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment