def padded_key(key, symbols, filter=True):
 syms = list(uniq(symbols))
 if (len(syms) != len(symbols)):
  extra = ''.join(sorted(set([i for i in symbols if (symbols.count(i) > 1)])))
  raise ValueError(('duplicate characters in symbols: %s' % extra))
 extra = (set(key) - set(syms))
 if extra:
  raise ValueError(('characters in key but not symbols: %s' % ''.join(sorted(extra))))
 key0 = ''.join(list(uniq(key)))
 return (key0 + ''.join([i for i in syms if (i not in key0)]))

def padded_key ( key , symbols , filter = True ) : syms = list ( uniq ( symbols ) ) if ( len ( syms ) != len ( symbols ) ) : extra = '' . join ( sorted ( set ( [ i for i in symbols if ( symbols . count ( i ) > 1 ) ] ) ) ) raise ValueError ( ( 'duplicate characters in symbols: %s' % extra ) ) extra = ( set ( key ) - set ( syms ) ) if extra : raise ValueError ( ( 'characters in key but not symbols: %s' % '' . join ( sorted ( extra ) ) ) ) key0 = '' . join ( list ( uniq ( key ) ) ) return ( key0 + '' . join ( [ i for i in syms if ( i not in key0 ) ] ) )
return a string of the distinct characters of symbols with those of key appearing first .