code: def _expand_config_values(section, key):
          
  
          def expand_environment_and_home(value):
              """
              Expands environment variables and the home directory (~).
  
              $FOO and ${FOO}-style environment variables are expanded, if they
              exist. If they do not exist, they are left unchanged.
              The exception are the following $XDG_* variables that are
              expanded to fallback values, if they are empty or not set:
              $XDG_CONFIG_HOME
              $XDG_CACHE_HOME
  
              :param value: configuration string
              :type value: str
              """
              xdg_vars = {'XDG_CONFIG_HOME': '~/.config',
                          'XDG_CACHE_HOME': '~/.cache'}
  
              for xdg_name, fallback in xdg_vars.items():
                  if xdg_name in value:
                      xdg_value = get_xdg_env(xdg_name, fallback)
                      value = value.replace('$%s' % xdg_name, xdg_value)\
                                   .replace('${%s}' % xdg_name, xdg_value)
              return os.path.expanduser(os.path.expandvars(value))
  
          value = section[key]
  
          if isinstance(value, str):
              section[key] = expand_environment_and_home(value)
          elif isinstance(value, (list, tuple)):
              new = list()
              for item in value:
                  if isinstance(item, str):
                      new.append(expand_environment_and_home(item))
                  else:
                      new.append(item)
              section[key] = new
docs: Walker function for ConfigObj.walk
  
          Applies expand_environment_and_home to all configuration values that
          are strings (or strings that are elements of tuples/lists)
  
          :param section: as passed by ConfigObj.walk
          :param key: as passed by ConfigObj.walk