New sections are indicated by a section marker line. The marker can have comments before it and an inline comment after it: the current section) are designated by repeating the square brackets before and after the section name.
You would typically use this to create a default Config Obj and then merge in user settings.
This way users only need to specify values that are different from the default.
The current version is 5.0.6, dated 25th August 2014. We still expect to pick up a few bugs along the way though, particularly with respect to Python 3 compatibility .
We recommend downloading and installing using pip: method will return a list of lines instead of writing to file. Here we show creating an empty Config Obj, setting a filename and some values, and then writing to file : , and section markers are between square brackets.
Here’s an example to illustrate: # This is the 'initial_comment' # Which may be several lines keyword1 = value1 'keyword 2' = 'value 2' [ "section 1" ] # This comment goes with keyword 3 keyword 3 = value 3 'keyword 4' = value4, value 5, 'value 6' sub-section # an inline comment # sub-section is inside "section 1" 'keyword 5' = 'value 7' 'keyword 6' = ''' A multiline value, that spans more than one line :-) The line breaks are included in the value.''' [ sub-sub-section ] # sub-sub-section is *in* 'sub-section' # which is in 'section 1' 'keyword 7' = 'value 8' [section 2] # an inline comment keyword8 = "value 9" keyword9 = value10 # an inline comment # The 'final_comment' # Which also may be several lines method of sections is a recursive update.
You can use this to merge sections, or even whole Config Objs, into each other.If You can use this for transforming all values in your Config Obj.For example you might like the nested lists from Config Obj 3. You could switch off the parsing for list values ( for tab.If the Config Obj is created from an existing file, it will contain any lines of comments before the start of the members.If you create a new Config Obj, this will be an empty list. It exists primarily to support the reading of the configspec - but has other use cases.It also causes comments to be copied from the configspec into the config file.