Oct-27-2019, 06:10 AM
is this way?
class host: fan_speed = { '0':'Not Applicable', '1':'Unknown', '2':'Half Speed', '3':'Full Speed', '4':'Low Speed' } fan_status = { '1':'Unknown', '2':'Fan Removed', '3':'Up', '4':'Fail', '5':'Out of Service' } def __init__(self,host,community,version,timeout): self.host = host self.community = community self.version = version self.timeout = timeout self.fan_speed = {} self.fan_status = {} def get_fan_speed(self, value): return self.fan_speed.get(value,"other") a = host('10.10.10.1','cacti',2,5)Dict get is not correct value
Output:print(a.get_fan_speed('2'))
other