So I am trying to create a class that will have already read in the file and have all functions of configparser plus a few more. Code looks like this:
import configparser
class dkconfig(configparser):
def __init__(self):
self.clusterini = os.path.abspath("..\\cluster.ini")
super(dkconfig,self).__init__(allow_no_value=True)
if os.path.exists(self.clusterini):
self.read(self.clusterini)
def getHostnames(self):
hostnames = {}
for sec in self.config.sections():
if sec.startswith("node"):
hostnames[sec] = self.config.get(sec, "hostname")
return hostnames
And its called from another script like so:
config = dkconfig()
names = config.getHostnames()
opts = config.options("node1")
The error says: TypeError: module.__init__() takes at most 2 arguments (3 given)
What am I missing and how can I have all instances of the "dkconfig" object already have the "cluster.ini" file read-in during construction?