The maketrans
is used to map the characters so that they match. First you pass a string with the characters that will be "translated", then the mapping of it, where position one of the map, corresponds to the translation of the first element of the passed string.
This can be seen in the following example:
from string import maketrans
char_a_ser_convertida = 'abcdef'
mapa_de_traducao = 'ABCDEF'
traducao = maketrans(char_a_ser_convertida, mapa_de_traducao)
str = 'abcg'
print str.translate(traducao)
The output of this print
will be:
ABCg
See that it has converted only the mapped characters to their corresponding characters on the map. Basically what it does is translate a character to a corresponding element in the mapping string.