def dict_union(*dicts, **kwargs):
 dicts = list(dicts)
 if (dicts and isinstance(dicts[0], OrderedDict)):
  result = OrderedDict()
 else:
  result = {}
 for d in (list(dicts) + [kwargs]):
  duplicate_keys = (set(result.keys()) & set(d.keys()))
  if duplicate_keys:
   raise ValueError('The following keys have duplicate entries: {}'.format(', '.join((str(key) for key in duplicate_keys))))
  result.update(d)
 return result

def dict_union ( * dicts , ** kwargs ) : dicts = list ( dicts ) if ( dicts and isinstance ( dicts [ 0 ] , OrderedDict ) ) : result = OrderedDict ( ) else : result = { } for d in ( list ( dicts ) + [ kwargs ] ) : duplicate_keys = ( set ( result . keys ( ) ) & set ( d . keys ( ) ) ) if duplicate_keys : raise ValueError ( 'The following keys have duplicate entries: {}' . format ( ', ' . join ( ( str ( key ) for key in duplicate_keys ) ) ) ) result . update ( d ) return result
return union of a sequence of disjoint dictionaries .