This code returns an error: AttributeError: can't set attribute
This is really a pity because I would like to use properties instead of calling the methods. Does anyone know why this simple example is not working?
#!/usr/bin/python2.6
class Bar( object ):
"""
...
"""
@property
def value():
"""
...
"""
def fget( self ):
return self._value
def fset(self, value ):
self._value = value
class Foo( object ):
def __init__( self ):
self.bar = Bar()
self.bar.value = "yyy"
if __name__ == '__main__':
foo = Foo()
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…