populate class from ini using configparser

This is the place for queries that don't fit in any of the other categories.

populate class from ini using configparser

Postby tbaror » Sun Jul 07, 2013 8:13 pm

I am newbie with python , started to write some system administration utility that should read info from INI file

Now i need to init a class based of ini sections , my question how can i do that send all info parameters key val with following example

Please advice Thanks

Code: Select all
class FopsTest():
    def __init__(self,**kwargs):
        self.variables = kwargs
   
    def set_foptype(self,FILEOP):
        self.variables['FILEOP'] = FLOPTYPE

cfgfile = os.getcwd() +'\wtrconfig.cfg'
config = configparser.ConfigParser()

os.path.exists(cfgfile)
config.sections()
config.read(cfgfile)

test = FopsTest(<pass ini key,val?>)
tbaror
 
Posts: 10
Joined: Sun Jul 07, 2013 8:06 pm

Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 1 guest