Created
May 17, 2014 22:57
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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