Python Forum
first try with python class, suggestion for improvement please
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
first try with python class, suggestion for improvement please
#10
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
Reply


Messages In This Thread
RE: first try with python class, suggestion for improvement please - by anna - Oct-27-2019, 06:10 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Suggestion on how to speed up this code? sawtooth500 1 259 May-04-2024, 07:13 PM
Last Post: sawtooth500
  Can you give me some suggestion about PCEP Newbie1114 0 1,051 Oct-14-2021, 03:02 PM
Last Post: Newbie1114
  instagram followers name without suggestion for you jacklee26 1 3,220 Oct-02-2021, 04:57 AM
Last Post: ndc85430
  Random coordinate generator speed improvement saidc 0 2,085 Aug-01-2021, 11:09 PM
Last Post: saidc
  Python Dev suggestion: Combining line-wrap with comments inside functions NikoNiels 2 1,775 Sep-26-2020, 07:45 PM
Last Post: bowlofred
  Function Improvement Santino 1 1,842 May-23-2020, 03:30 PM
Last Post: jefsummers
  Name Mashup Program Improvement in Python rhat398 3 2,637 Apr-05-2020, 12:09 PM
Last Post: perfringo
  Optimization suggestion Julia 2 1,771 Mar-29-2020, 12:02 PM
Last Post: Julia
  Need suggestion how to handle this error farrukh 1 2,322 Dec-21-2019, 03:21 PM
Last Post: DeaD_EyE
  Python Based Data QA Automation tool suggestion Sonia567 1 2,032 Nov-19-2019, 04:46 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020