[Python-checkins] CVS: python/dist/src/Doc/lib libcfgparser.tex,1.20,1.21

Fred L. Drake fdrake@users.sourceforge.net
Fri, 07 Dec 2001 13:35:59 -0800


Update of /cvsroot/python/python/dist/src/Doc/lib
In directory usw-pr-cvs1:/tmp/cvs-serv7719/lib

Modified Files:
	libcfgparser.tex 
Log Message:
Describe the behavior of the read() method when the list of filenames
includes files that do not exist, explain the intended use of the interface,
and show how to ensure an expected file really exists.
This closes SF bug #490399.


Index: libcfgparser.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcfgparser.tex,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** libcfgparser.tex	2001/10/09 14:58:24	1.20
--- libcfgparser.tex	2001/12/07 21:35:57	1.21
***************
*** 136,139 ****
--- 136,157 ----
  Read and parse a list of filenames.  If \var{filenames} is a string or
  Unicode string, it is treated as a single filename.
+ If a file named in \var{filenames} cannot be opened, that file will be
+ ignored.  This is designed so that you can specify a list of potential
+ configuration file locations (for example, the current directory, the
+ user's home directory, and some system-wide directory), and all
+ existing configuration files in the list will be read.  If none of the
+ named files exist, the \class{ConfigParser} instance will contain an
+ empty dataset.  An application which requires initial values to be
+ loaded from a file should load the required file or files using
+ \method{readfp()} before calling \method{read()} for any optional
+ files:
+ 
+ \begin{verbatim}
+ import ConfigParser, os
+ 
+ config = ConfigParser.ConfigParser()
+ config.readfp(open('defaults.cfg'))
+ config.read(['site.cfg', os.path.expanduser('~/.myapp.cfg')])
+ \end{verbatim}
  \end{methoddesc}