[code.view]

[top] / python / PyMOTW / ConfigParser / ConfigParser_remove.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')
     
     print 'Read values:\n'
     for section in parser.sections():
         print section
         for name, value in parser.items(section):
             print '  %s = %r' % (name, value)
     
     parser.remove_option('bug_tracker', 'password')
     parser.remove_section('wiki')
             
     print '\nModified values:\n'
     for section in parser.sections():
         print section
         for name, value in parser.items(section):
             print '  %s = %r' % (name, value)
     

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

contact | logmethods.com