Created
March 22, 2012 11:12
-
-
Save mingyc/2157719 to your computer and use it in GitHub Desktop.
Example of the usage of built-in property() function.
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 Circle(object): | |
def __init__(self, radius): | |
self._radius = radius | |
def _get_radius(self): | |
return self._radius | |
def _set_radius(self, value): | |
self._radius = value | |
def _del_radius(self): | |
del self._radius | |
radius = property(_get_radius, _set_radius, _del_radius, "The radius of the Circle.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment