167 | | == Listing available options == #listing_options |
| 167 | == Listing known options == #listing_options |
| 168 | Beside retrieving the value of a certain option, there are also methods for listing all known options. |
| 169 | |
| 170 | * `config.sections()`: Returns a list of the names of all known sections. |
| 171 | * `config.options(section_name)`: Returns a list of `(name, value)` tuples for all known options in the specified section. |
| 172 | * `config.defaults()`: Returns a dict with the default values of all known options (that have one) in all known sections. |
| 173 | |
| 174 | A "known option" in this context is an option that |
| 175 | |
| 176 | * is defined like described in the section [#defining_options Defining Options] above |
| 177 | * and/or has value assigned to it. |
| 178 | |
| 179 | Furthermore, there is a way to list all ''defined'' options. This is done by using `Option.registry` which is a dict with `(section_name, option_name)` keys. The value for each key is the `Option` object that defines the option (not its current value). The following example will list the descriptions of all defined options: |
| 180 | |
| 181 | {{{ |
| 182 | #!python |
| 183 | for (section_name, option_name), option in Option.registry.items(): |
| 184 | print option.__doc__ |
| 185 | }}} |