Skip to content

Instantly share code, notes, and snippets.

@un33k
Last active January 4, 2016 01:28
Show Gist options
  • Save un33k/8548232 to your computer and use it in GitHub Desktop.
Save un33k/8548232 to your computer and use it in GitHub Desktop.
getter & setter example
class GetterSetterExample(object):
_some_local_attribute = 1
@property
def some_attribute(self):
return self._some_local_attribute
@some_attribute.setter
def some_attribute(self, value):
self._some_local_attribute = value
# Usage
gs = GetterSetterExample()
print gs.some_attribute
# 1
gs.some_attribute = 2
print gs.some_attribute
# 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment