properties

Classic ASP - passing a property as byref

你离开我真会死。 提交于 2020-11-29 09:24:26
问题 In classic ASP I have an object, call it bob . This then has a property called name , with let and get methods. I have a function as follows: sub append(byref a, b) a = a & b end sub This is simply to make it quicker to add text to a variable. I also have the same for prepend , just it is a = b & a . I know it would be simple to say bob.name = bob.name & "andy" , but I tried using the above functions and neither of them work. The way I am calling it is append bob.name, "andy" . Can anyone see

'str' object is not callable when trying to set object property

风流意气都作罢 提交于 2020-11-29 08:50:20
问题 Having such object class testDec(object): def __init__(self): self.__x = 'stuff' @property def x(self): print 'called getter' return self.__x @x.setter def x(self, value): print 'called setter' self.__x = value Why I can not set attribute __x ? Here is a traceback >>> a.x called getter 'stuff' >>> a.x(11) called getter Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'str' object is not callable I'm using 2.7.6 Python 回答1: The syntax for properties looks like