Created
January 22, 2010 01:12
-
-
Save tomthepythonist/283410 to your computer and use it in GitHub Desktop.
This file contains hidden or 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._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