Yurttas/PL/SL/python/docs/core-python-programming/doc/20/lib/ConfigParser-objects.html
Jump to navigation
Jump to search
5.7.1 ConfigParser Objects
ConfigParser instances have the following methods:
- defaults ()
- Return a dictionary containing the instance-wide defaults.
- sections ()
- Return a list of the sections available;
DEFAULTis not included in the list.
- add_section (section)
- Add a section named section to the instance. If a section by the given name already exists, DuplicateSectionError is raised.
- has_section (section)
- Indicates whether the named section is present in the configuration. The
DEFAULTsection is not acknowledged.
- options (section)
- Returns a list of options available in the specified section.
- has_option (section, option)
- If the given section exists, and contains the given option. return 1; otherwise return 0. (New in 1.6)
- read (filenames)
- Read and parse a list of filenames. If filenames is a string or Unicode string, it is treated as a single filename.
- readfp (fp[, filename])
- Read and parse configuration data from the file or file-like object in fp (only the readline() method is used). If filename is omitted and fp has a name attribute, that is used for filename; the default is "<???>".
- get (section, option[, raw[, vars]])
- Get an option value for the provided section. All the "%" interpolations are expanded in the return values, based on the defaults passed into the constructor, as well as the options vars provided, unless the raw argument is true.
- getint (section, option)
- A convenience method which coerces the option in the specified section to an integer.
- getfloat (section, option)
- A convenience method which coerces the option in the specified section to a floating point number.
- getboolean (section, option)
- A convenience method which coerces the option in the specified section to a boolean value. Note that the only accepted values for the option are "0" and "1", any others will raise ValueError.
- set (section, option, value)
- If the given section exists, set the given option to the specified value; otherwise raise NoSectionError. (New in 1.6)
- write (fileobject)
- Write a representation of the configuration to the specified file object. This representation can be parsed by a future read() call. (New in 1.6)
- remove_option (section, option)
- Remove the specified option from the specified section. If the section does not exist, raise NoSectionError. If the option existed to be removed, return 1; otherwise return 0. (New in 1.6)
- remove_section (section)
- Remove the specified section from the configuration. If the section in fact existed, return 1. Otherwise return 0.
See About this document... for information on suggesting changes.