I want to write a Hebrew string in Python and then show it onscreen. The problem is that I get a mirror view of what I wrote. How can I set the string to use RTL instead of left to right?
Asked
Active
Viewed 1.0k times
14
-
4Do you use any GUI library to show it on screen? Or maybe you just print it to console? – liori Oct 04 '10 at 14:58
-
It's not pretty, but have you tried .reverse()? ;) – Herman Schaaf Oct 04 '10 at 15:13
-
3There's more to proper Hebrew typesetting than just the display order! These ‘advanced text layout’ features are dealt with by GUI apps (eg using Uniscribe or Pango), but are pretty much out of reach for console apps. – bobince Oct 04 '10 at 15:27
-
1I can't use reverse(); I didn't find the function. The GUI I use is PsychoPy. Thank you for your help – Or D Oct 05 '10 at 18:43
2 Answers
14
Did you try this?
http://pypi.python.org/pypi/python-bidi/
http://pypi.python.org/pypi/django-bidi-utils
The Israeli FOSS community is doing a lot in this direction. Surprisingly, they happily collaborate also with Farsi speakers :-)
-
-
No need to use ! It's like you are yelling ... Thanks for enlightening us – oz123 Feb 21 '20 at 06:21
-
-
1@Mahdi It's neither Pharsi, nor Farsi, In English it's called Persian. It's like you say Dutch instead of German – Ahmad Dec 16 '20 at 06:48
6
I know I'm pretty late to the party, but you can always use:
" שלום hello "[::-1]
But the real solution is to use:
from bidi.algorithm import get_display
print(get_display("היי"))

Salek
- 449
- 1
- 10
- 19

Stav Cohen
- 119
- 1
- 9