BlogGalleryAbout meContact
Jaganadh's bookshelf: read

Python Text Processing with NTLK 2.0 CookbookPython 2.6 Text Processing Beginners Guide

More of Jaganadh's books »
Jaganadh Gopinadhan's  book recommendations, reviews, quotes, book clubs, book trivia, book lists
Ubuntu GNU/Linux I am nerdier than 94% of all people. Are you a nerd? Click here to take the Nerd Test, get nerdy images and jokes, and write on the nerd forum! Python

Bangalore

Python3 ZWJ and Malayalam; some doubts

Again I tried to do something in Python3. But it resulted in some strange results.
See the below given code.

    ==== Code Begin =========

    def ജഗന്‍ ():
        print("എന്റെ പേര് ജഗന്‍ എന്നാണ്")
        ജഗന്‍  = "ഞാന്‍"
        print(ജഗന്‍  )

    ജഗന്‍ ()

==== Code End ===========

When I tried to execute this it throws some error.

    ~/pypract$ python3 tes2.py
      File "tes2.py", line 2
        def ജഗന്‍ ():
                          ^
    SyntaxError: invalid character in identifier

    ~/pypract$

I thought that it may be due to the use of
'ZWJ' in some names I used in function names and variable names. So I decided to rewrite the same without 'ZWJ' character. The code is given below

    ==== Code Begin =====
    def ജഗന്‍():
        print("എന്റെ പേര് ജഗന്‍ എന്നാണ്")
        ജഗന്‍= "ഞാന്‍"
        print(ജഗന്‍)

    ജഗന്‍()
    ==== Code End =======

This code executed with out any error. What I did is I replaced the ന്‍ with the Unicode 5.1 equivalent .
The output is

    /pypract$ python3 tester.py
    എന്റെ പേര് ജഗന്‍ എന്നാണ്
    ഞാന്‍

I can't understand what is happening. Is a logical mistake I made in my program!!!
Or is it a problem related to ZWJ and Python????

Related Entries:
Again Python programming in Malayalam
Book Review: Python 2.6 Text Processing Beginner's Guide by Jeff McNei
Python3 is wonderful
Using Yahoo! Term Extractor web service with Python
Python workshop at Kongu Engineering College, Perundurai
Comments (1)  Permalink

Comments

Carl T. @ 11.10.2009 05:21 GMT
jaggu,

I had similar problems to the one's you had in Konsole (I'm on KDE). I had to use Idel (Tkinter) to get it to work. I blogged about this:

http://pyright.blogspot.com/2009/10/python-3031-and-unicode-identifiers.html

I suspect it would work in Konsole (or Gnome's terminal) if the locale is set in a certain way, but don't quote me on it.

For now, I'm working with vim and Idle (Tkinter) as I outlined in my blog.

Thanks for posting this. It's linked to on the PythonWiki's Malayam page:

http://wiki.python.org/moin/MalayalamLanguage

Carl T.
No new comments allowed (anymore) on this post.