14

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?

Or D
  • 151
  • 1
  • 1
  • 9
  • 4
    Do 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
  • 3
    There'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
  • 1
    I 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 Answers2

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 :-)

pyfribidi for windows or any other bidi algorithm

Abra
  • 19,142
  • 7
  • 29
  • 41
oz123
  • 27,559
  • 27
  • 125
  • 187
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