Assigning to values from protocol buffer - python

When I try to assign the humidity values in python to a float value

def humidity_data_callback(self, data):
humidity_info = sense_pb2.Humidity().FromString(data[0]).humidity()
self.readings[‘humidity’] = humidity_info

I receive the following error message:

File “humidity.py”, line 22, in humidity_data_callback
humidity_info = sense_pb2.Humidity().FromString(data[0]).humidity()
TypeError: ‘float’ object is not callable

How do I assign the humidity to a variable?

Thanks.

hmm you i think you are trying to access a class instance variable as a function so better:

def humidity_data_callback(self, data):
    humidity_info = sense_pb2.Humidity().FromString(data[0]) # <-- set the Humidity instance from string
    self.readings[‘humidity’] = humidity_info.humidity # <-- humidity instance variable in the Humidity Class