With respect to what @andreas-doehler said: A dictionary would be nicer, IMHO. You could replace the above by section[line[1]] = line
, discover yield from *(Service(item=k) for k in section)
and in the check use the pattern
data = section.get(item)
if data is None:
return
id_, _, state, enable, pulse_count = data
But: A list should be fine. If you return None
, processing stops. As if no data were fetched.