astro py:docs

- Index
- Modules

### Navigation

- next »
- « previous |
- Astropy v5.2.1 »
- Configuration System (`astropy.config`) »
- ConfigNamespace

# ConfigNamespace

class astropy.config.ConfigNamespace

  Bases: `object`

  A namespace of configuration items. Each subpackage with configuration items should define a subclass of this class, containing `ConfigItem` instances as members.

  For example:

      class Conf(_config.ConfigNamespace):
          unicode_output = _config.ConfigItem(
              False,
              'Use Unicode characters when outputting values, ...')
          use_color = _config.ConfigItem(
              sys.platform != 'win32',
              'When True, use ANSI color escape sequences when ...',
              aliases=['astropy.utils.console.USE_COLOR'])
      conf = Conf()

  Methods Summary

  `items`() | Iterate over configuration item `(name, value)` pairs.
  `keys`() | Iterate over configuration item names.
  `reload`([attr]) | Reload a configuration item from the configuration file.
  `reset`([attr]) | Reset a configuration item to its default.
  `set_temp`(attr, value) | Temporarily set a configuration value.
  `values`() | Iterate over configuration item values.

  Methods Documentation

  items()

    Iterate over configuration item `(name, value)` pairs.

  keys()

    Iterate over configuration item names.

  reload(attr=None)

    Reload a configuration item from the configuration file.

    Parameters:
      attr `python:str`, optional

        The name of the configuration parameter to reload. If not provided, reload all configuration parameters.

  reset(attr=None)

    Reset a configuration item to its default.

    Parameters:
      attr `python:str`, optional

        The name of the configuration parameter to reload. If not provided, reset all configuration parameters.

  set_temp(attr, value)

    Temporarily set a configuration value.

    Parameters:
      attr `python:str`

        Configuration item name

      value `object`

        The value to set temporarily.

    Examples

        >>> import astropy
        >>> with astropy.conf.set_temp('use_color', False):
        ...     pass
        ...     # console output will not contain color
        >>> # console output contains color again...

  values()

    Iterate over configuration item values.