File tree 1 file changed +24
-0
lines changed
1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -135,6 +135,30 @@ involves the ``DEFAULT`` section which provides default values for all other
135
135
sections [1 ]_. Note also that keys in sections are
136
136
case-insensitive and stored in lowercase [1 ]_.
137
137
138
+ It is possible to read several configurations into a single
139
+ :class: `ConfigParser `, where the most recently added configuration has the
140
+ highest priority. Any conflicting keys are taken from the more recent
141
+ configuration while the previously existing keys are retained.
142
+
143
+ .. doctest ::
144
+
145
+ >>> another_config = configparser.ConfigParser()
146
+ >>> another_config.read(' example.ini' )
147
+ ['example.ini']
148
+ >>> another_config[' topsecret.server.com' ][' Port' ]
149
+ '50022'
150
+ >>> another_config.read_string(" [topsecret.server.com]\n Port=48484" )
151
+ >>> another_config[' topsecret.server.com' ][' Port' ]
152
+ '48484'
153
+ >>> another_config.read_dict({" topsecret.server.com" : {" Port" : 21212 }})
154
+ >>> another_config[' topsecret.server.com' ][' Port' ]
155
+ '21212'
156
+ >>> another_config[' topsecret.server.com' ][' ForwardX11' ]
157
+ 'no'
158
+
159
+ This behaviour is equivalent to a :meth: `ConfigParser.read ` call with several
160
+ files passed to the *filenames * parameter.
161
+
138
162
139
163
Supported Datatypes
140
164
-------------------
You can’t perform that action at this time.
0 commit comments