ConfigParser question

Carlos Molina cmolina at
Tue Jan 14 18:45:11 CET 2003


I'm new to python (i come from perl) and I am doing a little program...
My question is with ConfigParser class..

If I have the following conf file

recursive = /home/cmolina
recursive = /etc
recursive = /tmp/usr

logfile = ids.loga

and here, the simple code

import ConfigParser,os,getopt,sys
config = ConfigParser.ConfigParser()
config_file = 'test.conf'

def main():

def parse_config():
       logfile = config.get('options','logfile')
       # Colocamos en una lista las secciones
       options = config.options('dirs')
       print config.get('dirs','recursive')

def parse_command_options():
               (options,arguments) = 
               print "Options: ",options
               print "Arguments: ", arguments
       except getopt.GetoptError,error:
               return 0
       if options == []:
              def usage():
       print """
       IDS v0.0.1a
       ERROR: Opcion desconocida o no se colocaron argumentos necearios
       Uso: --md5 --init --check

If you run the scripot like this

./ --md5

I get this

Options:  [('--md5', '')]
Arguments:  []

What happens with the others recursive options values..??
I tried to push the get method to a list, but, always it returns the 
last recursive options values...

IS there a way that I can manage this situation...??

Thanks a lot


More information about the Python-list mailing list