<!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN">
<link rel=
"STYLESHEET" href=
"lib.css" type='text/css'
/>
<link rel=
"SHORTCUT ICON" href=
"../icons/pyfav.png" type=
"image/png" />
<link rel='start' href='../index.html' title='Python Documentation Index'
/>
<link rel=
"first" href=
"lib.html" title='Python Library Reference'
/>
<link rel='contents' href='contents.html'
title=
"Contents" />
<link rel='index' href='genindex.html' title='Index'
/>
<link rel='last' href='about.html' title='About this document...'
/>
<link rel='help' href='about.html' title='About this document...'
/>
<link rel=
"next" href=
"ConfigParser-objects.html" />
<link rel=
"prev" href=
"module-ConfigParser.html" />
<link rel=
"parent" href=
"module-ConfigParser.html" />
<link rel=
"next" href=
"ConfigParser-objects.html" />
<meta name='aesop' content='information'
/>
<title>5.17.1 RawConfigParser Objects
</title>
<div id='top-navigation-panel' xml:id='top-navigation-panel'
>
<table align=
"center" width=
"100%" cellpadding=
"0" cellspacing=
"2">
<td class='online-navigation'
><a rel=
"prev" title=
"5.17 ConfigParser "
href=
"module-ConfigParser.html"><img src='../icons/previous.png'
border='
0' height='
32' alt='Previous Page' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"parent" title=
"5.17 ConfigParser "
href=
"module-ConfigParser.html"><img src='../icons/up.png'
border='
0' height='
32' alt='Up One Level' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"next" title=
"5.17.2 ConfigParser Objects"
href=
"ConfigParser-objects.html"><img src='../icons/next.png'
border='
0' height='
32' alt='Next Page' width='
32'
/></A></td>
<td align=
"center" width=
"100%">Python Library Reference
</td>
<td class='online-navigation'
><a rel=
"contents" title=
"Table of Contents"
href=
"contents.html"><img src='../icons/contents.png'
border='
0' height='
32' alt='Contents' width='
32'
/></A></td>
<td class='online-navigation'
><a href=
"modindex.html" title=
"Module Index"><img src='../icons/modules.png'
border='
0' height='
32' alt='Module Index' width='
32'
/></a></td>
<td class='online-navigation'
><a rel=
"index" title=
"Index"
href=
"genindex.html"><img src='../icons/index.png'
border='
0' height='
32' alt='Index' width='
32'
/></A></td>
<div class='online-navigation'
>
<b class=
"navlabel">Previous:
</b>
<a class=
"sectref" rel=
"prev" href=
"module-ConfigParser.html">5.17 ConfigParser
</A>
<b class=
"navlabel">Up:
</b>
<a class=
"sectref" rel=
"parent" href=
"module-ConfigParser.html">5.17 ConfigParser
</A>
<b class=
"navlabel">Next:
</b>
<a class=
"sectref" rel=
"next" href=
"ConfigParser-objects.html">5.17.2 ConfigParser Objects
</A>
<!--End of Navigation Panel-->
<H2><A NAME=
"SECTION0071710000000000000000"></A><A NAME=
"RawConfigParser-objects"></A>
5.17.1 RawConfigParser Objects
<tt class=
"class">RawConfigParser
</tt> instances have the following methods:
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
1414' xml:id='l2h-
1414'
class=
"method">defaults
</tt></b>(
</nobr></td>
<td><var></var>)
</td></tr></table></dt>
Return a dictionary containing the instance-wide defaults.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
1415' xml:id='l2h-
1415'
class=
"method">sections
</tt></b>(
</nobr></td>
<td><var></var>)
</td></tr></table></dt>
Return a list of the sections available;
<code>DEFAULT
</code> is not
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
1416' xml:id='l2h-
1416'
class=
"method">add_section
</tt></b>(
</nobr></td>
<td><var>section
</var>)
</td></tr></table></dt>
Add a section named
<var>section
</var> to the instance. If a section by
the given name already exists,
<tt class=
"exception">DuplicateSectionError
</tt> is
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
1417' xml:id='l2h-
1417'
class=
"method">has_section
</tt></b>(
</nobr></td>
<td><var>section
</var>)
</td></tr></table></dt>
Indicates whether the named section is present in the
configuration. The
<code>DEFAULT
</code> section is not acknowledged.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
1418' xml:id='l2h-
1418'
class=
"method">options
</tt></b>(
</nobr></td>
<td><var>section
</var>)
</td></tr></table></dt>
Returns a list of options available in the specified
<var>section
</var>.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
1419' xml:id='l2h-
1419'
class=
"method">has_option
</tt></b>(
</nobr></td>
<td><var>section, option
</var>)
</td></tr></table></dt>
If the given section exists, and contains the given option,
return
<tt class=
"constant">True
</tt>; otherwise return
<tt class=
"constant">False
</tt>.
<span class=
"versionnote">New in version
1.6.
</span>
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
1420' xml:id='l2h-
1420'
class=
"method">read
</tt></b>(
</nobr></td>
<td><var>filenames
</var>)
</td></tr></table></dt>
Attempt to read and parse a list of filenames, returning a list of filenames
which were successfully parsed. If
<var>filenames
</var> is a string or
Unicode string, it is treated as a single filename.
If a file named in
<var>filenames
</var> 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
<tt class=
"class">ConfigParser
</tt> 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
<tt class=
"method">readfp()
</tt> before calling
<tt class=
"method">read()
</tt> for any optional
<div class=
"verbatim"><pre>
config = ConfigParser.ConfigParser()
config.readfp(open('defaults.cfg'))
config.read(['site.cfg', os.path.expanduser('~/.myapp.cfg')])
<span class=
"versionnote">Changed in version
2.4:
Returns list of successfully parsed filenames.
</span>
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
1421' xml:id='l2h-
1421'
class=
"method">readfp
</tt></b>(
</nobr></td>
<td><var>fp
</var><big>[
</big><var>, filename
</var><big>]
</big><var></var>)
</td></tr></table></dt>
Read and parse configuration data from the file or file-like object in
<var>fp
</var> (only the
<tt class=
"method">readline()
</tt> method is used). If
<var>filename
</var> is omitted and
<var>fp
</var> has a
<tt class=
"member">name
</tt> attribute,
that is used for
<var>filename
</var>; the default is
"<tt class="samp
"><???></tt>".
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
1422' xml:id='l2h-
1422'
class=
"method">get
</tt></b>(
</nobr></td>
<td><var>section, option
</var>)
</td></tr></table></dt>
Get an
<var>option
</var> value for the named
<var>section
</var>.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
1423' xml:id='l2h-
1423'
class=
"method">getint
</tt></b>(
</nobr></td>
<td><var>section, option
</var>)
</td></tr></table></dt>
A convenience method which coerces the
<var>option
</var> in the specified
<var>section
</var> to an integer.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
1424' xml:id='l2h-
1424'
class=
"method">getfloat
</tt></b>(
</nobr></td>
<td><var>section, option
</var>)
</td></tr></table></dt>
A convenience method which coerces the
<var>option
</var> in the specified
<var>section
</var> to a floating point number.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
1425' xml:id='l2h-
1425'
class=
"method">getboolean
</tt></b>(
</nobr></td>
<td><var>section, option
</var>)
</td></tr></table></dt>
A convenience method which coerces the
<var>option
</var> in the specified
<var>section
</var> to a Boolean value. Note that the accepted values
for the option are
<code>"1"</code>,
<code>"yes"</code>,
<code>"true"</code>, and
<code>"on"</code>,
which cause this method to return
<code>True
</code>, and
<code>"0"</code>,
<code>"no"</code>,
<code>"false"</code>, and
<code>"off"</code>, which cause it to return
<code>False
</code>. These
string values are checked in a case-insensitive manner. Any other value will
cause it to raise
<tt class=
"exception">ValueError
</tt>.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
1426' xml:id='l2h-
1426'
class=
"method">items
</tt></b>(
</nobr></td>
<td><var>section
</var>)
</td></tr></table></dt>
Return a list of
<code>(
<var>name
</var>,
<var>value
</var>)
</code> pairs for each
option in the given
<var>section
</var>.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
1427' xml:id='l2h-
1427'
class=
"method">set
</tt></b>(
</nobr></td>
<td><var>section, option, value
</var>)
</td></tr></table></dt>
If the given section exists, set the given option to the specified
value; otherwise raise
<tt class=
"exception">NoSectionError
</tt>. While it is
possible to use
<tt class=
"class">RawConfigParser
</tt> (or
<tt class=
"class">ConfigParser
</tt> with
<var>raw
</var> parameters set to true) for
<em>internal
</em> storage of
non-string values, full functionality (including interpolation and
output to files) can only be achieved using string values.
<span class=
"versionnote">New in version
1.6.
</span>
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
1428' xml:id='l2h-
1428'
class=
"method">write
</tt></b>(
</nobr></td>
<td><var>fileobject
</var>)
</td></tr></table></dt>
Write a representation of the configuration to the specified file
object. This representation can be parsed by a future
<tt class=
"method">read()
</tt>
<span class=
"versionnote">New in version
1.6.
</span>
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
1429' xml:id='l2h-
1429'
class=
"method">remove_option
</tt></b>(
</nobr></td>
<td><var>section, option
</var>)
</td></tr></table></dt>
Remove the specified
<var>option
</var> from the specified
<var>section
</var>.
If the section does not exist, raise
<tt class=
"exception">NoSectionError
</tt>.
If the option existed to be removed, return
<tt class=
"constant">True
</tt>;
otherwise return
<tt class=
"constant">False
</tt>.
<span class=
"versionnote">New in version
1.6.
</span>
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
1430' xml:id='l2h-
1430'
class=
"method">remove_section
</tt></b>(
</nobr></td>
<td><var>section
</var>)
</td></tr></table></dt>
Remove the specified
<var>section
</var> from the configuration.
If the section in fact existed, return
<code>True
</code>.
Otherwise return
<code>False
</code>.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
1431' xml:id='l2h-
1431'
class=
"method">optionxform
</tt></b>(
</nobr></td>
<td><var>option
</var>)
</td></tr></table></dt>
Transforms the option name
<var>option
</var> as found in an input file or
as passed in by client code to the form that should be used in the
internal structures. The default implementation returns a lower-case
version of
<var>option
</var>; subclasses may override this or client code
can set an attribute of this name on instances to affect this
behavior. Setting this to
<tt class=
"function">str()
</tt>, for example, would make
option names case sensitive.
<div class='online-navigation'
>
<table align=
"center" width=
"100%" cellpadding=
"0" cellspacing=
"2">
<td class='online-navigation'
><a rel=
"prev" title=
"5.17 ConfigParser "
href=
"module-ConfigParser.html"><img src='../icons/previous.png'
border='
0' height='
32' alt='Previous Page' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"parent" title=
"5.17 ConfigParser "
href=
"module-ConfigParser.html"><img src='../icons/up.png'
border='
0' height='
32' alt='Up One Level' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"next" title=
"5.17.2 ConfigParser Objects"
href=
"ConfigParser-objects.html"><img src='../icons/next.png'
border='
0' height='
32' alt='Next Page' width='
32'
/></A></td>
<td align=
"center" width=
"100%">Python Library Reference
</td>
<td class='online-navigation'
><a rel=
"contents" title=
"Table of Contents"
href=
"contents.html"><img src='../icons/contents.png'
border='
0' height='
32' alt='Contents' width='
32'
/></A></td>
<td class='online-navigation'
><a href=
"modindex.html" title=
"Module Index"><img src='../icons/modules.png'
border='
0' height='
32' alt='Module Index' width='
32'
/></a></td>
<td class='online-navigation'
><a rel=
"index" title=
"Index"
href=
"genindex.html"><img src='../icons/index.png'
border='
0' height='
32' alt='Index' width='
32'
/></A></td>
<div class='online-navigation'
>
<b class=
"navlabel">Previous:
</b>
<a class=
"sectref" rel=
"prev" href=
"module-ConfigParser.html">5.17 ConfigParser
</A>
<b class=
"navlabel">Up:
</b>
<a class=
"sectref" rel=
"parent" href=
"module-ConfigParser.html">5.17 ConfigParser
</A>
<b class=
"navlabel">Next:
</b>
<a class=
"sectref" rel=
"next" href=
"ConfigParser-objects.html">5.17.2 ConfigParser Objects
</A>
<span class=
"release-info">Release
2.4.2, documentation updated on
28 September
2005.
</span>
<!--End of Navigation Panel-->
See
<i><a href=
"about.html">About this document...
</a></i> for information on suggesting changes.