Created
January 24, 2012 15:56
-
-
Save Alquimista/1670817 to your computer and use it in GitHub Desktop.
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 MyClass(object): | |
def __init__(self): | |
self._foo = "foo" | |
self._bar = "bar" | |
def foo(): | |
doc = "property foo's doc string" | |
def fget(self): | |
return self._foo | |
def fset(self, value): | |
self._foo = value | |
def fdel(self): | |
del self._foo | |
return locals() # credit: David Niergarth | |
foo = property(**foo()) | |
def bar(): | |
doc = "bar is readonly" | |
def fget(self): | |
return self._bar | |
return locals() | |
bar = property(**bar()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment