code: def _resolve_variable(cls, config, substitution):
          
          variable = substitution.variable
          try:
              return True, config.get(variable)
          except ConfigMissingException:
              # default to environment variable
              value = os.environ.get(variable)
  
              if value is None:
                  if substitution.optional:
                      return False, None
                  else:
                      raise ConfigSubstitutionException(
                          "Cannot resolve variable ${{{variable}}} (line: {line}, col: {col})".format(
                              variable=variable,
                              line=lineno(substitution.loc, substitution.instring),
                              col=col(substitution.loc, substitution.instring)))
              elif isinstance(value, ConfigList) or isinstance(value, ConfigTree):
                  raise ConfigSubstitutionException(
                      "Cannot substitute variable ${{{variable}}} because it does not point to a "
                      "string, int, float, boolean or null {type} (line:{line}, col: {col})".format(
                          variable=variable,
                          type=value.__class__.__name__,
                          line=lineno(substitution.loc, substitution.instring),
                          col=col(substitution.loc, substitution.instring)))
              return True, value
docs: :param config:
          :param substitution:
          :return: (is_resolved, resolved_variable)