(string, expansions)
return string
Expands ${VARIABLES}, $(VARIABLES), and $VARIABLES in string per the
  expansions list. If the variable expands to something that references
  another variable, this variable is expanded as well if it's in env --
  until no variables present in env are left.
Expands ${VARIABLES}, $(VARIABLES), and $VARIABLES in string per the
  expansions list. If the variable expands to something that references
  another variable, this variable is expanded as well if it's in env --
  until no variables present in env are left.
Expands $ { VARIABLES } $ ( VARIABLES ) and $VARIABLES in string per the expansions list . If the variable expands to something that references another variable this variable is expanded as well if it s in env -- until no variables present in env are left .
def ExpandEnvVars(string, expansions):
  """Expands ${VARIABLES}, $(VARIABLES), and $VARIABLES in string per the
  expansions list. If the variable expands to something that references
  another variable, this variable is expanded as well if it's in env --
  until no variables present in env are left."""
  for k, v in reversed(expansions):
    string = string.replace('${' + k + '}', v)
    string = string.replace('$(' + k + ')', v)
    string = string.replace('$' + k, v)
  return string
def ExpandEnvVars ( string , expansions ) : for k , v in reversed ( expansions ) : string = string . replace ( '${' + k + '}' , v ) string = string . replace ( '$(' + k + ')' , v ) string = string . replace ( '$' + k , v ) return string