Module base
[hide private]
[frames] | no frames]

Source Code for Module base

 1  #!/usr/bin/python3 
 2  """ This module implements the base class for almost everything""" 
 3   
 4   
5 -class Base(object):
6 """ 7 """ 8
9 - def __init__(self, name, descr=None):
10 """ 11 """ 12 self.name = name 13 self.description = descr 14 self.attributes = {}
15
16 - def __str__(self):
17 """ 18 """ 19 if self.description is None: 20 return self.name 21 return "{}({})".format(self.name, self.description)
22
23 - def get(self, attribute):
24 """ 25 """ 26 if attribute in self.attributes: 27 return self.attributes[attribute] 28 return None
29
30 - def set(self, attribute, value):
31 """ 32 """ 33 self.attributes[attribute] = value
34