On Mon, Oct 24, 2016 at 1:30 PM, Mikhail V email@example.com wrote:
But how would you with current translate function drop all characters that are not in the table?
that is another question altogether, and one for a different list, actually.
I don't know a way to do "remove every character except these", but someone I expect there is a way to do that efficiently with Python strings.
you could probably (ab)use the codecs module, though.
If there really is no way to do it, then you might have feature worth pursuing, but be prepared with use-cases!
The only use-case I've had for that sort of this is when I want only ASCII -- but I can uses the ascii codec for that :-)
This for example
is needed for filtering out all non-standard characters from paths, etc.
You'd usually want to replace those with something, rather than remove them entirely, yes?
So in other words, there should be an option to control this behavior. Probably I am missing something here, but I didn't find such solution for translate() and that is main point of proposal actually. It is all the same as translate() but with this extension it can cover much more usage cases.