[Python-checkins] r75016 - python/branches/py3k/Doc/library/configparser.rst

georg.brandl python-checkins at python.org
Tue Sep 22 15:53:15 CEST 2009


Author: georg.brandl
Date: Tue Sep 22 15:53:14 2009
New Revision: 75016

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

Modified:
   python/branches/py3k/Doc/library/configparser.rst

Modified: python/branches/py3k/Doc/library/configparser.rst
==============================================================================
--- python/branches/py3k/Doc/library/configparser.rst	(original)
+++ python/branches/py3k/Doc/library/configparser.rst	Tue Sep 22 15:53:14 2009
@@ -231,9 +231,11 @@
 .. method:: RawConfigParser.readfp(fp, filename=None)
 
    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*
-   has a :attr:`name` attribute, that is used for *filename*; the default is
-   ``<???>``.
+   (only the :meth:`readline` method is used).  The file-like object must
+   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)
@@ -279,8 +281,9 @@
 
 .. method:: RawConfigParser.write(fileobject)
 
-   Write a representation of the configuration to the specified file object.  This
-   representation can be parsed by a future :meth:`read` call.
+   Write a representation of the configuration to the specified file object,
+   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)
@@ -370,7 +373,7 @@
    config.set('Section1', 'foo', '%(bar)s is %(baz)s!')
 
    # Writing our configuration file to 'example.cfg'
-   with open('example.cfg', 'wb') as configfile:
+   with open('example.cfg', 'w') as configfile:
        config.write(configfile)
 
 An example of reading the configuration file again::


More information about the Python-checkins mailing list