I need to make a very fast n-dirty input disinfection, and I would like to basically convert everything <, > to <, > .
I would like to achieve the same results as '<script></script>'.replace('<', '<').replace('>', '>') without repeating the line several times. I know about maketrans in combination with str.translate (i.e. http://www.tutorialspoint.com/python/string_translate.htm ), but this only converts from 1 char to another char. In other words, you cannot do something like:
inList = '<>' outList = ['<', '>'] transform = maketrans(inList, outList)
Is there a builtin function that can perform this conversion in one iteration?
I would like to use the builtin features as opposed to external modules. I already know about Bleach .
source share