Skip to content

Instantly share code, notes, and snippets.

@justinfay
Last active November 23, 2016 17:00
Show Gist options
  • Save justinfay/8d17ecd58befe9524e8d to your computer and use it in GitHub Desktop.
Save justinfay/8d17ecd58befe9524e8d to your computer and use it in GitHub Desktop.
def private():
"""
Factory function for creating Private instances.
"""
def _():
_.attr = 0
class Private(object):
"""
class with one private attribute and method to increment.
"""
@property
def attr(self):
return _.attr
def add_one(self):
_.attr += 1
return Private()
return _()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment