Fred Drake | bc866ce | 1999-01-26 15:47:59 +0000 | [diff] [blame] | 1 | \section{\module{ConfigParser} --- |
Fred Drake | 4747f7f | 1999-04-21 16:41:40 +0000 | [diff] [blame] | 2 | Configuration file parser} |
Fred Drake | bc866ce | 1999-01-26 15:47:59 +0000 | [diff] [blame] | 3 | |
| 4 | \declaremodule{standard}{ConfigParser} |
Fred Drake | bc866ce | 1999-01-26 15:47:59 +0000 | [diff] [blame] | 5 | \modulesynopsis{Configuration file parser.} |
Andrew M. Kuchling | c62af02 | 2004-01-08 15:01:08 +0000 | [diff] [blame] | 6 | \moduleauthor{Ken Manheimer}{klm@zope.com} |
Fred Drake | 38e5d27 | 2000-04-03 20:13:55 +0000 | [diff] [blame] | 7 | \moduleauthor{Barry Warsaw}{bwarsaw@python.org} |
Eric S. Raymond | 417c489 | 2000-07-10 18:11:00 +0000 | [diff] [blame] | 8 | \moduleauthor{Eric S. Raymond}{esr@thyrsus.com} |
Fred Drake | bc866ce | 1999-01-26 15:47:59 +0000 | [diff] [blame] | 9 | \sectionauthor{Christopher G. Petrilli}{petrilli@amber.org} |
| 10 | |
Fred Drake | 1e44029 | 1999-06-15 17:30:59 +0000 | [diff] [blame] | 11 | This module defines the class \class{ConfigParser}. |
| 12 | \indexii{.ini}{file}\indexii{configuration}{file}\index{ini file} |
| 13 | \index{Windows ini file} |
| 14 | The \class{ConfigParser} class implements a basic configuration file |
Fred Drake | bc866ce | 1999-01-26 15:47:59 +0000 | [diff] [blame] | 15 | parser language which provides a structure similar to what you would |
Fred Drake | 81e4aa7 | 2002-12-30 23:50:19 +0000 | [diff] [blame] | 16 | find on Microsoft Windows INI files. You can use this to write Python |
Fred Drake | bc866ce | 1999-01-26 15:47:59 +0000 | [diff] [blame] | 17 | programs which can be customized by end users easily. |
| 18 | |
Fred Drake | 81e4aa7 | 2002-12-30 23:50:19 +0000 | [diff] [blame] | 19 | \begin{notice}[warning] |
| 20 | This library does \emph{not} interpret or write the value-type |
| 21 | prefixes used in the Windows Registry extended version of INI syntax. |
| 22 | \end{notice} |
| 23 | |
Eric S. Raymond | 56b3184 | 2002-12-27 20:05:36 +0000 | [diff] [blame] | 24 | The configuration file consists of sections, led by a |
Fred Drake | bc866ce | 1999-01-26 15:47:59 +0000 | [diff] [blame] | 25 | \samp{[section]} header and followed by \samp{name: value} entries, |
Fred Drake | 1e44029 | 1999-06-15 17:30:59 +0000 | [diff] [blame] | 26 | with continuations in the style of \rfc{822}; \samp{name=value} is |
Fred Drake | 38e5d27 | 2000-04-03 20:13:55 +0000 | [diff] [blame] | 27 | also accepted. Note that leading whitespace is removed from values. |
| 28 | The optional values can contain format strings which refer to other |
| 29 | values in the same section, or values in a special |
Fred Drake | 97d5f05 | 2002-10-25 20:20:58 +0000 | [diff] [blame] | 30 | \code{DEFAULT} section. Additional defaults can be provided on |
Fred Drake | 38e5d27 | 2000-04-03 20:13:55 +0000 | [diff] [blame] | 31 | initialization and retrieval. Lines beginning with \character{\#} or |
| 32 | \character{;} are ignored and may be used to provide comments. |
Fred Drake | bc866ce | 1999-01-26 15:47:59 +0000 | [diff] [blame] | 33 | |
| 34 | For example: |
| 35 | |
| 36 | \begin{verbatim} |
Fred Drake | 97d5f05 | 2002-10-25 20:20:58 +0000 | [diff] [blame] | 37 | [My Section] |
Fred Drake | bc866ce | 1999-01-26 15:47:59 +0000 | [diff] [blame] | 38 | foodir: %(dir)s/whatever |
Fred Drake | 38e5d27 | 2000-04-03 20:13:55 +0000 | [diff] [blame] | 39 | dir=frob |
Fred Drake | bc866ce | 1999-01-26 15:47:59 +0000 | [diff] [blame] | 40 | \end{verbatim} |
| 41 | |
Fred Drake | 38e5d27 | 2000-04-03 20:13:55 +0000 | [diff] [blame] | 42 | would resolve the \samp{\%(dir)s} to the value of |
| 43 | \samp{dir} (\samp{frob} in this case). All reference expansions are |
| 44 | done on demand. |
Fred Drake | bc866ce | 1999-01-26 15:47:59 +0000 | [diff] [blame] | 45 | |
Fred Drake | 38e5d27 | 2000-04-03 20:13:55 +0000 | [diff] [blame] | 46 | Default values can be specified by passing them into the |
| 47 | \class{ConfigParser} constructor as a dictionary. Additional defaults |
| 48 | may be passed into the \method{get()} method which will override all |
Fred Drake | ebe2a12 | 1999-01-26 21:49:05 +0000 | [diff] [blame] | 49 | others. |
Fred Drake | bc866ce | 1999-01-26 15:47:59 +0000 | [diff] [blame] | 50 | |
Fred Drake | 97d5f05 | 2002-10-25 20:20:58 +0000 | [diff] [blame] | 51 | \begin{classdesc}{RawConfigParser}{\optional{defaults}} |
| 52 | The basic configuration object. When \var{defaults} is given, it is |
| 53 | initialized into the dictionary of intrinsic defaults. This class |
| 54 | does not support the magical interpolation behavior. |
| 55 | \versionadded{2.3} |
| 56 | \end{classdesc} |
| 57 | |
Fred Drake | bc866ce | 1999-01-26 15:47:59 +0000 | [diff] [blame] | 58 | \begin{classdesc}{ConfigParser}{\optional{defaults}} |
Fred Drake | 97d5f05 | 2002-10-25 20:20:58 +0000 | [diff] [blame] | 59 | Derived class of \class{RawConfigParser} that implements the magical |
Skip Montanaro | 6485a87 | 2003-12-15 14:38:57 +0000 | [diff] [blame] | 60 | interpolation feature and adds optional arguments to the \method{get()} |
Fred Drake | 97d5f05 | 2002-10-25 20:20:58 +0000 | [diff] [blame] | 61 | and \method{items()} methods. The values in \var{defaults} must be |
Fred Drake | bc866ce | 1999-01-26 15:47:59 +0000 | [diff] [blame] | 62 | appropriate for the \samp{\%()s} string interpolation. Note that |
Fred Drake | 33dde92 | 2000-09-27 22:48:44 +0000 | [diff] [blame] | 63 | \var{__name__} is an intrinsic default; its value is the section name, |
| 64 | and will override any value provided in \var{defaults}. |
Fred Drake | bc12b01 | 2004-05-18 02:25:51 +0000 | [diff] [blame] | 65 | |
| 66 | All option names used in interpolation will be passed through the |
| 67 | \method{optionxform()} method just like any other option name |
| 68 | reference. For example, using the default implementation of |
| 69 | \method{optionxform()} (which converts option names to lower case), |
| 70 | the values \samp{foo \%(bar)s} and \samp{foo \%(BAR)s} are |
| 71 | equivalent. |
Fred Drake | bc866ce | 1999-01-26 15:47:59 +0000 | [diff] [blame] | 72 | \end{classdesc} |
| 73 | |
Fred Drake | 0eebd5c | 2002-10-25 21:52:00 +0000 | [diff] [blame] | 74 | \begin{classdesc}{SafeConfigParser}{\optional{defaults}} |
| 75 | Derived class of \class{ConfigParser} that implements a more-sane |
| 76 | variant of the magical interpolation feature. This implementation is |
| 77 | more predictable as well. |
| 78 | % XXX Need to explain what's safer/more predictable about it. |
| 79 | New applications should prefer this version if they don't need to be |
| 80 | compatible with older versions of Python. |
| 81 | \versionadded{2.3} |
| 82 | \end{classdesc} |
| 83 | |
Fred Drake | bc866ce | 1999-01-26 15:47:59 +0000 | [diff] [blame] | 84 | \begin{excdesc}{NoSectionError} |
| 85 | Exception raised when a specified section is not found. |
| 86 | \end{excdesc} |
| 87 | |
| 88 | \begin{excdesc}{DuplicateSectionError} |
Fred Drake | b4c6091 | 2004-05-18 03:56:51 +0000 | [diff] [blame] | 89 | Exception raised if \method{add_section()} is called with the name of |
| 90 | a section that is already present. |
Fred Drake | bc866ce | 1999-01-26 15:47:59 +0000 | [diff] [blame] | 91 | \end{excdesc} |
| 92 | |
| 93 | \begin{excdesc}{NoOptionError} |
| 94 | Exception raised when a specified option is not found in the specified |
| 95 | section. |
| 96 | \end{excdesc} |
| 97 | |
| 98 | \begin{excdesc}{InterpolationError} |
Fred Drake | e2c6491 | 2002-12-31 17:23:27 +0000 | [diff] [blame] | 99 | Base class for exceptions raised when problems occur performing string |
| 100 | interpolation. |
Fred Drake | bc866ce | 1999-01-26 15:47:59 +0000 | [diff] [blame] | 101 | \end{excdesc} |
| 102 | |
Fred Drake | 33dde92 | 2000-09-27 22:48:44 +0000 | [diff] [blame] | 103 | \begin{excdesc}{InterpolationDepthError} |
| 104 | Exception raised when string interpolation cannot be completed because |
| 105 | the number of iterations exceeds \constant{MAX_INTERPOLATION_DEPTH}. |
Fred Drake | e2c6491 | 2002-12-31 17:23:27 +0000 | [diff] [blame] | 106 | Subclass of \exception{InterpolationError}. |
| 107 | \end{excdesc} |
| 108 | |
| 109 | \begin{excdesc}{InterpolationMissingOptionError} |
| 110 | Exception raised when an option referenced from a value does not exist. |
| 111 | Subclass of \exception{InterpolationError}. |
| 112 | \versionadded{2.3} |
Fred Drake | 33dde92 | 2000-09-27 22:48:44 +0000 | [diff] [blame] | 113 | \end{excdesc} |
| 114 | |
Fred Drake | 81e4aa7 | 2002-12-30 23:50:19 +0000 | [diff] [blame] | 115 | \begin{excdesc}{InterpolationSyntaxError} |
| 116 | Exception raised when the source text into which substitutions are |
| 117 | made does not conform to the required syntax. |
Fred Drake | e2c6491 | 2002-12-31 17:23:27 +0000 | [diff] [blame] | 118 | Subclass of \exception{InterpolationError}. |
Neal Norwitz | 99448e5 | 2002-12-31 12:23:10 +0000 | [diff] [blame] | 119 | \versionadded{2.3} |
Fred Drake | 81e4aa7 | 2002-12-30 23:50:19 +0000 | [diff] [blame] | 120 | \end{excdesc} |
| 121 | |
Fred Drake | bc866ce | 1999-01-26 15:47:59 +0000 | [diff] [blame] | 122 | \begin{excdesc}{MissingSectionHeaderError} |
| 123 | Exception raised when attempting to parse a file which has no section |
| 124 | headers. |
| 125 | \end{excdesc} |
| 126 | |
| 127 | \begin{excdesc}{ParsingError} |
| 128 | Exception raised when errors occur attempting to parse a file. |
| 129 | \end{excdesc} |
| 130 | |
Fred Drake | 33dde92 | 2000-09-27 22:48:44 +0000 | [diff] [blame] | 131 | \begin{datadesc}{MAX_INTERPOLATION_DEPTH} |
| 132 | The maximum depth for recursive interpolation for \method{get()} when |
Fred Drake | 97d5f05 | 2002-10-25 20:20:58 +0000 | [diff] [blame] | 133 | the \var{raw} parameter is false. This is relevant only for the |
| 134 | \class{ConfigParser} class. |
Fred Drake | 33dde92 | 2000-09-27 22:48:44 +0000 | [diff] [blame] | 135 | \end{datadesc} |
| 136 | |
Fred Drake | ebe2a12 | 1999-01-26 21:49:05 +0000 | [diff] [blame] | 137 | |
Fred Drake | 184e836 | 1999-05-11 15:14:15 +0000 | [diff] [blame] | 138 | \begin{seealso} |
| 139 | \seemodule{shlex}{Support for a creating \UNIX{} shell-like |
Fred Drake | e2c6491 | 2002-12-31 17:23:27 +0000 | [diff] [blame] | 140 | mini-languages which can be used as an alternate |
| 141 | format for application configuration files.} |
Fred Drake | 184e836 | 1999-05-11 15:14:15 +0000 | [diff] [blame] | 142 | \end{seealso} |
| 143 | |
Fred Drake | 5b0705d | 2001-02-19 22:37:24 +0000 | [diff] [blame] | 144 | |
Fred Drake | 97d5f05 | 2002-10-25 20:20:58 +0000 | [diff] [blame] | 145 | \subsection{RawConfigParser Objects \label{RawConfigParser-objects}} |
Fred Drake | bc866ce | 1999-01-26 15:47:59 +0000 | [diff] [blame] | 146 | |
Fred Drake | 97d5f05 | 2002-10-25 20:20:58 +0000 | [diff] [blame] | 147 | \class{RawConfigParser} instances have the following methods: |
Fred Drake | bc866ce | 1999-01-26 15:47:59 +0000 | [diff] [blame] | 148 | |
| 149 | \begin{methoddesc}{defaults}{} |
Fred Drake | 7cb42cd | 2000-05-23 02:28:26 +0000 | [diff] [blame] | 150 | Return a dictionary containing the instance-wide defaults. |
Fred Drake | bc866ce | 1999-01-26 15:47:59 +0000 | [diff] [blame] | 151 | \end{methoddesc} |
| 152 | |
| 153 | \begin{methoddesc}{sections}{} |
Fred Drake | 38e5d27 | 2000-04-03 20:13:55 +0000 | [diff] [blame] | 154 | Return a list of the sections available; \code{DEFAULT} is not |
| 155 | included in the list. |
| 156 | \end{methoddesc} |
| 157 | |
| 158 | \begin{methoddesc}{add_section}{section} |
| 159 | Add a section named \var{section} to the instance. If a section by |
| 160 | the given name already exists, \exception{DuplicateSectionError} is |
| 161 | raised. |
Fred Drake | bc866ce | 1999-01-26 15:47:59 +0000 | [diff] [blame] | 162 | \end{methoddesc} |
| 163 | |
| 164 | \begin{methoddesc}{has_section}{section} |
| 165 | Indicates whether the named section is present in the |
| 166 | configuration. The \code{DEFAULT} section is not acknowledged. |
| 167 | \end{methoddesc} |
| 168 | |
| 169 | \begin{methoddesc}{options}{section} |
| 170 | Returns a list of options available in the specified \var{section}. |
| 171 | \end{methoddesc} |
| 172 | |
Eric S. Raymond | 417c489 | 2000-07-10 18:11:00 +0000 | [diff] [blame] | 173 | \begin{methoddesc}{has_option}{section, option} |
Raymond Hettinger | 9b4dab4 | 2003-12-31 18:37:28 +0000 | [diff] [blame] | 174 | If the given section exists, and contains the given option, |
| 175 | return \constant{True}; otherwise return \constant{False}. |
Fred Drake | 3c10c68 | 2001-09-28 16:57:16 +0000 | [diff] [blame] | 176 | \versionadded{1.6} |
Eric S. Raymond | 417c489 | 2000-07-10 18:11:00 +0000 | [diff] [blame] | 177 | \end{methoddesc} |
| 178 | |
Fred Drake | bc866ce | 1999-01-26 15:47:59 +0000 | [diff] [blame] | 179 | \begin{methoddesc}{read}{filenames} |
Fred Drake | 8290314 | 2004-05-18 04:24:02 +0000 | [diff] [blame] | 180 | Attempt to read and parse a list of filenames, returning a list of filenames |
| 181 | which were successfully parsed. If \var{filenames} is a string or |
Fred Drake | d85f059 | 2000-05-09 15:06:32 +0000 | [diff] [blame] | 182 | Unicode string, it is treated as a single filename. |
Fred Drake | 8b7bb7a | 2001-12-07 21:35:57 +0000 | [diff] [blame] | 183 | If a file named in \var{filenames} cannot be opened, that file will be |
| 184 | ignored. This is designed so that you can specify a list of potential |
| 185 | configuration file locations (for example, the current directory, the |
| 186 | user's home directory, and some system-wide directory), and all |
| 187 | existing configuration files in the list will be read. If none of the |
| 188 | named files exist, the \class{ConfigParser} instance will contain an |
| 189 | empty dataset. An application which requires initial values to be |
| 190 | loaded from a file should load the required file or files using |
| 191 | \method{readfp()} before calling \method{read()} for any optional |
| 192 | files: |
| 193 | |
| 194 | \begin{verbatim} |
| 195 | import ConfigParser, os |
| 196 | |
| 197 | config = ConfigParser.ConfigParser() |
| 198 | config.readfp(open('defaults.cfg')) |
| 199 | config.read(['site.cfg', os.path.expanduser('~/.myapp.cfg')]) |
| 200 | \end{verbatim} |
Fred Drake | 8290314 | 2004-05-18 04:24:02 +0000 | [diff] [blame] | 201 | \versionchanged[Returns list of successfully parsed filenames]{2.4} |
Fred Drake | d85f059 | 2000-05-09 15:06:32 +0000 | [diff] [blame] | 202 | \end{methoddesc} |
| 203 | |
| 204 | \begin{methoddesc}{readfp}{fp\optional{, filename}} |
| 205 | Read and parse configuration data from the file or file-like object in |
| 206 | \var{fp} (only the \method{readline()} method is used). If |
| 207 | \var{filename} is omitted and \var{fp} has a \member{name} attribute, |
| 208 | that is used for \var{filename}; the default is \samp{<???>}. |
Fred Drake | bc866ce | 1999-01-26 15:47:59 +0000 | [diff] [blame] | 209 | \end{methoddesc} |
| 210 | |
Fred Drake | 97d5f05 | 2002-10-25 20:20:58 +0000 | [diff] [blame] | 211 | \begin{methoddesc}{get}{section, option} |
| 212 | Get an \var{option} value for the named \var{section}. |
Fred Drake | bc866ce | 1999-01-26 15:47:59 +0000 | [diff] [blame] | 213 | \end{methoddesc} |
| 214 | |
| 215 | \begin{methoddesc}{getint}{section, option} |
| 216 | A convenience method which coerces the \var{option} in the specified |
| 217 | \var{section} to an integer. |
| 218 | \end{methoddesc} |
| 219 | |
| 220 | \begin{methoddesc}{getfloat}{section, option} |
| 221 | A convenience method which coerces the \var{option} in the specified |
| 222 | \var{section} to a floating point number. |
| 223 | \end{methoddesc} |
| 224 | |
| 225 | \begin{methoddesc}{getboolean}{section, option} |
| 226 | A convenience method which coerces the \var{option} in the specified |
Fred Drake | b35f0ce | 2001-10-08 16:03:20 +0000 | [diff] [blame] | 227 | \var{section} to a Boolean value. Note that the accepted values |
Raymond Hettinger | fb85789 | 2003-08-14 19:58:35 +0000 | [diff] [blame] | 228 | for the option are \code{"1"}, \code{"yes"}, \code{"true"}, and \code{"on"}, |
| 229 | which cause this method to return \code{True}, and \code{"0"}, \code{"no"}, |
| 230 | \code{"false"}, and \code{"off"}, which cause it to return \code{False}. These |
| 231 | string values are checked in a case-insensitive manner. Any other value will |
Fred Drake | 6959a2f | 2001-10-09 14:58:24 +0000 | [diff] [blame] | 232 | cause it to raise \exception{ValueError}. |
Fred Drake | bc866ce | 1999-01-26 15:47:59 +0000 | [diff] [blame] | 233 | \end{methoddesc} |
Eric S. Raymond | 417c489 | 2000-07-10 18:11:00 +0000 | [diff] [blame] | 234 | |
Fred Drake | 97d5f05 | 2002-10-25 20:20:58 +0000 | [diff] [blame] | 235 | \begin{methoddesc}{items}{section} |
| 236 | Return a list of \code{(\var{name}, \var{value})} pairs for each |
| 237 | option in the given \var{section}. |
Fred Drake | 2ca041f | 2002-09-27 15:49:56 +0000 | [diff] [blame] | 238 | \end{methoddesc} |
| 239 | |
Eric S. Raymond | 417c489 | 2000-07-10 18:11:00 +0000 | [diff] [blame] | 240 | \begin{methoddesc}{set}{section, option, value} |
| 241 | If the given section exists, set the given option to the specified value; |
Fred Drake | abc086f | 2004-05-18 03:29:52 +0000 | [diff] [blame] | 242 | otherwise raise \exception{NoSectionError}. \var{value} must be a |
| 243 | string (\class{str} or \class{unicode}); if not, \exception{TypeError} |
| 244 | is raised. |
Fred Drake | 3c10c68 | 2001-09-28 16:57:16 +0000 | [diff] [blame] | 245 | \versionadded{1.6} |
Eric S. Raymond | 417c489 | 2000-07-10 18:11:00 +0000 | [diff] [blame] | 246 | \end{methoddesc} |
| 247 | |
Eric S. Raymond | f868de6 | 2000-07-14 15:00:02 +0000 | [diff] [blame] | 248 | \begin{methoddesc}{write}{fileobject} |
Eric S. Raymond | 417c489 | 2000-07-10 18:11:00 +0000 | [diff] [blame] | 249 | Write a representation of the configuration to the specified file |
| 250 | object. This representation can be parsed by a future \method{read()} |
Fred Drake | 3c10c68 | 2001-09-28 16:57:16 +0000 | [diff] [blame] | 251 | call. |
| 252 | \versionadded{1.6} |
Eric S. Raymond | 417c489 | 2000-07-10 18:11:00 +0000 | [diff] [blame] | 253 | \end{methoddesc} |
Eric S. Raymond | f868de6 | 2000-07-14 15:00:02 +0000 | [diff] [blame] | 254 | |
| 255 | \begin{methoddesc}{remove_option}{section, option} |
| 256 | Remove the specified \var{option} from the specified \var{section}. |
| 257 | If the section does not exist, raise \exception{NoSectionError}. |
Raymond Hettinger | 9b4dab4 | 2003-12-31 18:37:28 +0000 | [diff] [blame] | 258 | If the option existed to be removed, return \constant{True}; |
| 259 | otherwise return \constant{False}. |
Fred Drake | 3c10c68 | 2001-09-28 16:57:16 +0000 | [diff] [blame] | 260 | \versionadded{1.6} |
Eric S. Raymond | f868de6 | 2000-07-14 15:00:02 +0000 | [diff] [blame] | 261 | \end{methoddesc} |
| 262 | |
| 263 | \begin{methoddesc}{remove_section}{section} |
| 264 | Remove the specified \var{section} from the configuration. |
Neal Norwitz | d3dab2b | 2002-04-05 02:21:09 +0000 | [diff] [blame] | 265 | If the section in fact existed, return \code{True}. |
| 266 | Otherwise return \code{False}. |
Eric S. Raymond | f868de6 | 2000-07-14 15:00:02 +0000 | [diff] [blame] | 267 | \end{methoddesc} |
| 268 | |
Fred Drake | 5b0705d | 2001-02-19 22:37:24 +0000 | [diff] [blame] | 269 | \begin{methoddesc}{optionxform}{option} |
| 270 | Transforms the option name \var{option} as found in an input file or |
| 271 | as passed in by client code to the form that should be used in the |
| 272 | internal structures. The default implementation returns a lower-case |
| 273 | version of \var{option}; subclasses may override this or client code |
| 274 | can set an attribute of this name on instances to affect this |
| 275 | behavior. Setting this to \function{str()}, for example, would make |
| 276 | option names case sensitive. |
| 277 | \end{methoddesc} |
Fred Drake | 97d5f05 | 2002-10-25 20:20:58 +0000 | [diff] [blame] | 278 | |
| 279 | |
| 280 | \subsection{ConfigParser Objects \label{ConfigParser-objects}} |
| 281 | |
| 282 | The \class{ConfigParser} class extends some methods of the |
| 283 | \class{RawConfigParser} interface, adding some optional arguments. |
Fred Drake | bc12b01 | 2004-05-18 02:25:51 +0000 | [diff] [blame] | 284 | The \class{SafeConfigParser} class implements the same extended |
| 285 | interface. |
Fred Drake | 97d5f05 | 2002-10-25 20:20:58 +0000 | [diff] [blame] | 286 | |
| 287 | \begin{methoddesc}{get}{section, option\optional{, raw\optional{, vars}}} |
| 288 | Get an \var{option} value for the named \var{section}. All the |
| 289 | \character{\%} interpolations are expanded in the return values, based |
| 290 | on the defaults passed into the constructor, as well as the options |
| 291 | \var{vars} provided, unless the \var{raw} argument is true. |
| 292 | \end{methoddesc} |
| 293 | |
| 294 | \begin{methoddesc}{items}{section\optional{, raw\optional{, vars}}} |
Fred Drake | 86c60ed | 2003-10-21 16:50:55 +0000 | [diff] [blame] | 295 | Return a list of \code{(\var{name}, \var{value})} pairs for each |
| 296 | option in the given \var{section}. Optional arguments have the |
| 297 | same meaning as for the \method{get()} method. |
Fred Drake | 97d5f05 | 2002-10-25 20:20:58 +0000 | [diff] [blame] | 298 | \versionadded{2.3} |
| 299 | \end{methoddesc} |