Commit 73753d35 authored by Georg Brandl's avatar Georg Brandl

#6969: make it explicit that configparser writes/reads text files, and fix the example.

parent 8355e7c4
...@@ -231,9 +231,11 @@ RawConfigParser Objects ...@@ -231,9 +231,11 @@ RawConfigParser Objects
.. method:: RawConfigParser.readfp(fp, filename=None) .. method:: RawConfigParser.readfp(fp, filename=None)
Read and parse configuration data from the file or file-like object in *fp* Read and parse configuration data from the file or file-like object in *fp*
(only the :meth:`readline` method is used). If *filename* is omitted and *fp* (only the :meth:`readline` method is used). The file-like object must
has a :attr:`name` attribute, that is used for *filename*; the default is operate in text mode, i.e. return strings from :meth:`readline`.
``<???>``.
If *filename* is omitted and *fp* has a :attr:`name` attribute, that is used
for *filename*; the default is ``<???>``.
.. method:: RawConfigParser.get(section, option) .. method:: RawConfigParser.get(section, option)
...@@ -279,8 +281,9 @@ RawConfigParser Objects ...@@ -279,8 +281,9 @@ RawConfigParser Objects
.. method:: RawConfigParser.write(fileobject) .. method:: RawConfigParser.write(fileobject)
Write a representation of the configuration to the specified file object. This Write a representation of the configuration to the specified file object,
representation can be parsed by a future :meth:`read` call. which must be opened in text mode (accepting strings). This representation
can be parsed by a future :meth:`read` call.
.. method:: RawConfigParser.remove_option(section, option) .. method:: RawConfigParser.remove_option(section, option)
...@@ -370,7 +373,7 @@ An example of writing to a configuration file:: ...@@ -370,7 +373,7 @@ An example of writing to a configuration file::
config.set('Section1', 'foo', '%(bar)s is %(baz)s!') config.set('Section1', 'foo', '%(bar)s is %(baz)s!')
# Writing our configuration file to 'example.cfg' # Writing our configuration file to 'example.cfg'
with open('example.cfg', 'wb') as configfile: with open('example.cfg', 'w') as configfile:
config.write(configfile) config.write(configfile)
An example of reading the configuration file again:: An example of reading the configuration file again::
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment