[code.view]

[top] / python / PyMOTW / ConfigParser / ConfigParser_interpolation.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('interpolation.ini')
     
     print 'Original value       :', parser.get('bug_tracker', 'url')
     
     parser.set('bug_tracker', 'port', '9090')
     print 'Altered port value   :', parser.get('bug_tracker', 'url')
     
     print 'Without interpolation:', parser.get('bug_tracker', 'url', raw=True)
     

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

contact | logmethods.com