~ubuntu-branches/ubuntu/lucid/python2.6/lucid

« back to all changes in this revision

Viewing changes to Doc/library/configparser.rst

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-03-11 13:30:19 UTC
  • mto: (10.1.13 sid)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: james.westby@ubuntu.com-20100311133019-sblbooa3uqrkoe70
Tags: upstream-2.6.5~rc2
ImportĀ upstreamĀ versionĀ 2.6.5~rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
constructor as a dictionary.  Additional defaults  may be passed into the
57
57
:meth:`get` method which will override all others.
58
58
 
59
 
Sections are normally stored in a builtin dictionary. An alternative dictionary
 
59
Sections are normally stored in a built-in dictionary. An alternative dictionary
60
60
type can be passed to the :class:`ConfigParser` constructor. For example, if a
61
61
dictionary type is passed that sorts its keys, the sections will be sorted on
62
62
write-back, as will be the keys within each section.
317
317
 
318
318
.. method:: RawConfigParser.optionxform(option)
319
319
 
320
 
   Transforms the option name *option* as found in an input file or as passed in by
321
 
   client code to the form that should be used in the internal structures.  The
322
 
   default implementation returns a lower-case version of *option*; subclasses may
323
 
   override this or client code can set an attribute of this name on instances to
324
 
   affect this behavior.  Setting this to :func:`str`, for example, would make
325
 
   option names case sensitive.
 
320
   Transforms the option name *option* as found in an input file or as passed in
 
321
   by client code to the form that should be used in the internal structures.
 
322
   The default implementation returns a lower-case version of *option*;
 
323
   subclasses may override this or client code can set an attribute of this name
 
324
   on instances to affect this behavior.
 
325
 
 
326
   You don't necessarily need to subclass a ConfigParser to use this method, you
 
327
   can also re-set it on an instance, to a function that takes a string
 
328
   argument.  Setting it to ``str``, for example, would make option names case
 
329
   sensitive::
 
330
 
 
331
      cfgparser = ConfigParser()
 
332
      ...
 
333
      cfgparser.optionxform = str
 
334
 
 
335
   Note that when reading configuration files, whitespace around the
 
336
   option names are stripped before :meth:`optionxform` is called.
326
337
 
327
338
 
328
339
.. _configparser-objects: