Skip to content

Instantly share code, notes, and snippets.

@tomthepythonist
Created January 22, 2010 01:12
Show Gist options
  • Save tomthepythonist/283410 to your computer and use it in GitHub Desktop.
Save tomthepythonist/283410 to your computer and use it in GitHub Desktop.
class myclass(object):
def __init__(self):
self._x = 5
@property
def x(self):
return self._x
@x.setter
def x(self, value):
self._x = value
@x.deleter
def x(self):
del self._x
myobj = myclass()
print myobj.x
myobj.x = 20
print myobj.x
del myobj.x
try:print myobj.x
except:print "attribute has been deleted!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment