Skip to content

Instantly share code, notes, and snippets.

@pasberth
Created December 10, 2011 08:49
Show Gist options
  • Select an option

  • Save pasberth/1454842 to your computer and use it in GitHub Desktop.

Select an option

Save pasberth/1454842 to your computer and use it in GitHub Desktop.
class Count(object):
def __init__(self):
self.count = 0
def up(self):
try:
return self.count
finally:
self.count += 1
c = Count()
print c.count # 0
print c.up() # 0
print c.up() # 1
print c.up() # 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment