Skip to content

Instantly share code, notes, and snippets.

@fabiand
Created December 3, 2015 09:28
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 fabiand/8ef2817b82975d279efa to your computer and use it in GitHub Desktop.
Save fabiand/8ef2817b82975d279efa to your computer and use it in GitHub Desktop.
@contextmanager
def download_iso(w):
# do download
yield path_to_w
# do removal
with downloaded_iso("centos") as isopath:
# do stuff
##### THIS IS EQUAL TO
try:
isopath = download_iso("centos")
# do stuff
except:
# foo
finally:
# do removal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment