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

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
expands ${variables} .