-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-37779 : Add information about the overriding behavior of ConfigParser.read #15177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
3ff9d28
b3ea855
73ea042
13ad7ab
3774983
8d9a084
42dc02a
196d4f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,6 +135,28 @@ involves the ``DEFAULT`` section which provides default values for all other | |
sections [1]_. Note also that keys in sections are | ||
case-insensitive and stored in lowercase [1]_. | ||
|
||
If it is necessary to read several configurations, with each one having more | ||
priority than the previous one, an instance of :class:`ConfigParser` can be | ||
used to override previously defined properties and retain existing ones. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One problem I see with this is that the first few clauses of this sentence seem to be introducing a tutorial, i.e. "If you want to do X, you can achieve it with Y", but then it turns out that you are actually describing the existing behavior of I would recommend rewriting this as an introduction to the properties of a
That's mostly an example, I'm not super happy with that particular wording... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
What do you think of this wording?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pganssle I pushed @aeros167 's version to the repository. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have made the requested changes; please review again |
||
|
||
.. doctest:: | ||
|
||
>>> config = configparser.ConfigParser() | ||
>>> config.read('example.ini') | ||
['example.ini'] | ||
>>> config['topsecret.server.com']['Port'] | ||
'50022' | ||
>>> config.read_string("[topsecret.server.com]\nPort=48484") | ||
>>> config['topsecret.server.com']['Port'] | ||
'48484' | ||
>>> config.read_dict({"topsecret.server.com": {"Port": 21212}}) | ||
>>> config['topsecret.server.com']['Port'] | ||
'21212' | ||
>>> config['topsecret.server.com']['ForwardX11'] | ||
'no' | ||
|
||
|
||
This behaviour is equivalent to a :meth:`ConfigParser.read` call with several files passed to ``filenames`` parameter. | ||
|
||
sblondon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Supported Datatypes | ||
------------------- | ||
|
Uh oh!
There was an error while loading. Please reload this page.