@contextlib.contextmanager
def _legalize_parameter_names(var_list):
 var_map = OrderedDict()
 for var in var_list:
  old_name = var.name
  new_name = old_name.replace('$', '_').replace('.', '_')
  assert (new_name not in var_map)
  var_map[new_name] = (var, old_name)
  var.name = new_name
 param_names = list(var_map)
 try:
  (yield param_names)
 finally:
  for (var, old_name) in var_map.values():
   var.name = old_name

@ contextlib . contextmanager def _legalize_parameter_names ( var_list ) : var_map = OrderedDict ( ) for var in var_list : old_name = var . name new_name = old_name . replace ( '$' , '_' ) . replace ( '.' , '_' ) assert ( new_name not in var_map ) var_map [ new_name ] = ( var , old_name ) var . name = new_name param_names = list ( var_map ) try : ( yield param_names ) finally : for ( var , old_name ) in var_map . values ( ) : var . name = old_name
legalize names in the variable list for use as a python functions parameter names .