[Python-ideas] Fwd: Add Unicode-aware str.reverse() function?

Jonathan Fine jfine2358 at gmail.com
Sat Sep 8 09:00:17 EDT 2018

Stephan Houben wrote:

> To be honest, quite apart from the Unicode issue, I never had a need to
> reverse a string in real code.
> .ytilibigel edepmi ot sdnet yllareneg tI

Sometimes we have to write 'backwards' to improve legibility. Odd
though that may sound.

Some languages are written from left to right. Some from right to
left. And some ancient writing alternates, line to line.


Users of modern rendering systems, such as in modern browsers, don't
have to worry about this. This is because the renderer will handle LTR
and RTL switches based on the language attribute. (Alway, text should
be encoded in reading order.)

But those implementing a bidectional rendering system might have to
worry about such things.

So what does that have to do with us, Python developers and users.
According to the web: Arabic, Hebrew, Persian, and Urdu are the most
widespread RTL writing systems in modern times.

To provide legible localised (translated) help messages at the
interactive Python interpreter, the system somewhere will have to
correctly reverse Unicode strings, either before or after processing
combining characters.

There are about 422 million Arabic speakers, 110 million Persian, 5
million Hebrew and 100 million Urdu. Definitely worth doing, in my
opinion. Otherwise the help message will look TO THEM like this:

     daer ot drah yrev si siht

instead of

      this is very hard to read


More information about the Python-ideas mailing list