Skip to content

Instantly share code, notes, and snippets.

@yuuichi-fujioka
Created February 25, 2014 06:49
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 yuuichi-fujioka/9204003 to your computer and use it in GitHub Desktop.
Save yuuichi-fujioka/9204003 to your computer and use it in GitHub Desktop.
with example
class Foo():
def __enter__(self):
print 'begin transaction'
return self
def __exit__(self, type, value, traceback):
if value:
print 'An error has occured in this transaction'
else:
print 'This transaction is success"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment