def hash_combination(combination):
 bits = []
 for (variable, value) in six.iteritems(combination):
  if (isinstance(variable, six.integer_types) and isinstance(value, six.integer_types)):
   bits.append((u'%d=%d' % (variable, value)))
  else:
   bits.append((u'%d=%d' % (variable.pk, value.pk)))
 bits.sort()
 raw_combination = u','.join(bits)
 hashed_combination = hashlib.sha1(force_bytes(raw_combination)).hexdigest()
 return hashed_combination

def hash_combination ( combination ) : bits = [ ] for ( variable , value ) in six . iteritems ( combination ) : if ( isinstance ( variable , six . integer_types ) and isinstance ( value , six . integer_types ) ) : bits . append ( ( u'%d=%d' % ( variable , value ) ) ) else : bits . append ( ( u'%d=%d' % ( variable . pk , value . pk ) ) ) bits . sort ( ) raw_combination = u',' . join ( bits ) hashed_combination = hashlib . sha1 ( force_bytes ( raw_combination ) ) . hexdigest ( ) return hashed_combination
calculate the combination hash for a given mapping of variable pks to value pks .