Skip to content

Instantly share code, notes, and snippets.

@hynek
Created May 19, 2013 20:40
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 hynek/5608909 to your computer and use it in GitHub Desktop.
Save hynek/5608909 to your computer and use it in GitHub Desktop.
class Foo:
_answer = 42
@property
def answer(self):
print('getting!')
return self._answer
@answer.setter
def answer(self, new_answer):
print('setting!')
self._answer = new_answer
f = Foo()
print(f.answer)
f.answer = 23
print(f.answer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment