Home > fedora, foss, fun, hack, python > Behaviour of ConfigParser.read() – Python

Behaviour of ConfigParser.read() – Python

I am playing around with python for a while. My code uses ConfigParser to parse a piece of configuration file. Now the documentation says ConfigParser.read() accepts list of file names as an argument and tries to read them one by one and returns the list of files that are read successfully.This behaviour is helpful when you have multiple configuration files all across your system.

what the documentation doesn’t tell you is, which configuration file it will use for further processing in case of multiple successful reads. ConfigParser actually uses the last read file for further processing. So prioritize your  configuration files accordingly

import ConfigParser

config_parser = ConfigParser.ConfigParser()

filenames = ['low_priority_file','medium_priority_file','high_priority_file']

config_parser.read(filenames)

About these ads
Categories: fedora, foss, fun, hack, python Tags: , ,
  1. January 25, 2013 at 5:40 pm

    That’s exactly what I’m looking for

    Thanks a lot

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 882 other followers

%d bloggers like this: