Skip to content

Instantly share code, notes, and snippets.

@avamsi
Created September 4, 2016 21:41
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 avamsi/a05cca98a5e26333280e2ec255ba9ef3 to your computer and use it in GitHub Desktop.
Save avamsi/a05cca98a5e26333280e2ec255ba9ef3 to your computer and use it in GitHub Desktop.
class JustAnotherClass(object):
_sentinel = object()
def __init__(self, value):
self.value = value
def consume1(self):
try:
return self.value
finally:
self.value = self._sentinel
def consume2(self):
_value = self.value
self.value = self._sentinel
return _value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment