开发者

Python: TypeError: 'float' object is not callable

开发者 https://www.devze.com 2022-12-13 02:56 出处:网络
I am trying to join 2 strings using this code: def __get_temp(self): return float(self.ask(\'RS\')) def __set_temp(self, temp):

I am trying to join 2 strings using this code:

def __get_temp(self):
    return float(self.ask('RS'))

def __set_temp(self, temp):
    set = ('SS' + repr(temp))
    stat = self.ask(set)
    return self.check(stat)

temp = property(__get_temp, __set_temp)

Once together, I then send a signal over a 开发者_如何学JAVAserial bus using PyVisa. However, when I try to call the function, I get

Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
chil.temp(13)
TypeError: 'float' object is not callable

I've tried looking around for explanation of this error, but none of them make any sense. Anyone know what is going on?


It looks like you are trying to set the property temp, but what you're actually doing is getting the property and then trying to call it as function with the parameter 13. The syntax for setting is:

chil.temp = 13
0

精彩评论

暂无评论...
验证码 换一张
取 消