The use cases you mention (with Django/Torch), and possibly some more. If you want to do some more archaeology, you might want to look at the Unix tr
command; it looks to me like translate
was inspired by that.
For things like replacing unwanted characters with underscores, in C back in 1999, a lookup table with (up to) 256 bytes would be the obvious choice. It wouldn’t need an explanation. The story of it becoming esoteric is quite interesting; thanks for digging up the Python leg of the journey :)
Nowadays, maybe we want something like teaching replace
to do multiple replacements instead. It seems that limiting the matches to single characters isn’t particularly important.
Of course, multireplace
has its own issues.