[code.view]

[top] / python / PyMOTW / ConfigParser / ConfigParser_structure.py

     #!/usr/bin/env python
     # encoding: utf-8
     #
     # Copyright (c) 2010 Doug Hellmann.  All rights reserved.
     #
     """Reading a configuration file.
     """
     #end_pymotw_header
     
     from ConfigParser import SafeConfigParser
     
     parser = SafeConfigParser()
     parser.read('multisection.ini')
     
     for section_name in parser.sections():
         print 'Section:', section_name
         print '  Options:', parser.options(section_name)
         for name, value in parser.items(section_name):
             print '  %s = %s' % (name, value)
         print
     

[top] / python / PyMOTW / ConfigParser / ConfigParser_structure.py

contact | logmethods.com