Python3 ZWJ and Malayalam; some doubts

Written by Jaganadh Gopinadhan

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????

Migrated from my old blog jaganadhg.freeflux.net

Written on October 6, 2009
The Opinions Expressed In This Post Are My Own And Not Necessarily Those Of My Employer.
[ Python  Python3  Malayalam  ]