Jan-16-2020, 07:44 AM
str.translate is for replacing character for character, string or None. So 'δ' -> 'delta_low' is possible, but 'delta_low' -> 'δ' is not.
.translate documentation:
>>> mapping = str.maketrans({"δ": 'delta_low'}) >>> 'Some measurement with δ did get get wrong'.translate(mapping) 'Some measurement with delta_low did get get wrong' >>> mapping = str.maketrans({'delta_low': "δ"}) /../ ValueError: string keys in translate table must be of length 1.maketrans documentation:
Quote:Character keys will be then converted to ordinals.
If there are two arguments, they must be strings of equal length, and
in the resulting dictionary, each character in x will be mapped to the
character at the same position in y.
.translate documentation:
Quote:Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.