Skip to content

Instantly share code, notes, and snippets.

@Alquimista
Created January 24, 2012 15:56
Show Gist options
  • Save Alquimista/1670817 to your computer and use it in GitHub Desktop.
Save Alquimista/1670817 to your computer and use it in GitHub Desktop.
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