Skip to content

Instantly share code, notes, and snippets.

@kevinconway
Created May 18, 2012 14:54
Show Gist options
  • Select an option

  • Save kevinconway/2725683 to your computer and use it in GitHub Desktop.

Select an option

Save kevinconway/2725683 to your computer and use it in GitHub Desktop.
Property decorator example for SuperToDo
class ToDo(object):
"""base ToDo class - simple datastructure for defining a ToDo Item"""
def __init__(self, description, location = None):
super(ToDo, self).__init__()
self._description = description
self._isThisDone = False
self._location = location
@property
def description():
def fget(self):
return self._description
def fset(self, newdesc):
self._description = newdesc
# Should be
class ToDo(object):
"""base ToDo class - simple datastructure for defining a ToDo Item"""
def __init__(self, description, location=None):
super(ToDo, self).__init__()
self._description = description
self._isThisDone = False
self._location = location
@property
def description(self):
return self._description if hasattr(self, '_description') else None
@description.setter
def description(self, d):
self._description = d
@description.deleter
def description(self):
del self._description
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment