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

Richard Damon Richard at Damon-Family.org
Sat Sep 8 17:20:17 EDT 2018

On 9/8/18 4:55 PM, Jonathan Fine wrote:
> Chris Angelico wrote:
>> Improving a rendering engine or console so it's capable of correct RTL
>> display is outside the scope of Python code, generally.
> I agree with you, generally.
> But there are over 600 million people who speak a RTL language. About
> 12% of the world's population. I'd like Python's command line console
> to work for them.
> It may be worth making a special effort, and breaking a general rule,
> here. But we'd have to think carefully about it, and have expert help.
> I'm beginning to think that, as well as (instead of?) IDLE, a browser
> based Python command line console might be a good idea. For example,
> I'm getting reasonable results from using
>       https://brython.info/tests/editor.html?lang=en
> Perhaps RTL and LTR problems by themselves are not sufficient reason
> to make a browser-based IDLE. But they should be a significant
> influence. Something to think about.
> By the way, IDLE has the same problem.
I would say that this shows that the problem isn't a need for a
Unicode-aware string reverse, as that won't handle the problem (and is
in someways the easiest part of the problem). The issue is that the
string is quite likely a combination of LTR and RTL codes, so you
perhaps want a functions to convert a Unicode string and process it so
the requested glyphs are now all in a LTR order (perhaps even adding the
override codes to the string so if the display DOES know how to handle
RTL text knows it isn't supposed to change the order).

Unicode is complicated, and one big question is how much support for its
complexity should be built into the language and the basic types.
Currently it is a fairly basic support (mostly just for codepoints). It
could make sense to have a Unicode package that knows a lot more of the
complexity of Unicode, doing things like extraction a code point package
that represents a full glyph knowing all the combining rules, and maybe
processing directional rendering like the above problem.

Richard Damon

More information about the Python-ideas mailing list