Skip to content

Instantly share code, notes, and snippets.

@jepio
Created May 17, 2014 22:57
Show Gist options
  • Save jepio/b717a1fc0ebcbbc75c01 to your computer and use it in GitHub Desktop.
Save jepio/b717a1fc0ebcbbc75c01 to your computer and use it in GitHub Desktop.
An example that shows more or less how to use the property decorator in python.
class Example(object):
def __init__(self, x=None, y=None):
self._x = x
self._y = y
@property
def x(self):
return self._x
@x.setter
def x(self, value):
self._x = value
@x.getter
def x(self):
return abs(self._x)
@property
def y(self):
return self._y
@y.setter
def y(self, value):
self._y = value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment