I am developing an application with check the status of a bunch of sensors.
The way to get their status is very straightforward:
sensor_name.get_status()Instead of writing several calls to check all those sensors, I was wondering if I could store all sensor names in a list of strings and let a for do the work for me.
Pretty much like this:
sensors_list = ['sensor_name_1', 'sensor_name_2', 'sensor_name_3'] for sensor in sensors_list: #call it :-)How can I get this done?
How about, instead of keeping the names in the list, you just keep the sensors themselves in the list?
sensors = [sensor_1, sensor_2, sensor3] for sensor in sensors: sensor.get_status()