Created
February 26, 2013 15:41
-
-
Save jqb/5039424 to your computer and use it in GitHub Desktop.
Nice pattern for clean property definiiton
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 Class(object): | |
def prop(self): | |
def fget(self): | |
# stuff to get the value | |
def fset(self, value): | |
# stuff to set the value | |
return locals() | |
prop = property(**prop()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment