BlogGalleryAbout meContact
My Resume
WebDOCPDF
RTFODTTXT
powered by emurse
Use OpenOffice.org Spread Firefox Affiliate Button Ubuntu GNU/Linux Perl Python SMC

Again Python programming in Malayalam

Today I tried Object Oriented Programming in Python (Python3) with Malayalam class names and variable names.

See the code. It works very well with Python3 interpreter.

    class പക്ഷി:

        def __init__(self):
            """
            ക്ലാസ് ഇനിഷ്യലൈസേഷന്‍
            """
            self.വിവിധ = ['കാക്ക','പ്രാവ്','കുരുവി','തത്ത','മൈന','പരുന്ത്','മൂങ്ങ']

        def പറക്കുക(self, ഇനം):
            """
            പറക്കുമോന്ന് നോക്കാല്ലോ!!!!!!!!!!!
            """
            if ഇനം in self.വിവിധ:
                print("%s പറക്കുന്ന പക്ഷിയാണ്" % ഇനം)
            else:
                print("എനിക്കറിയാമ്മേലേ!!!!!!")

    if __name__ == "__main__":
        സൂചകം = പക്ഷി()
        പറവ = "കാക്ക"
        മൃഗം = "ആന"
        സൂചകം.പറക്കുക(പറവ)
        സൂചകം.പറക്കുക(മൃഗം)


Use Python3 interpreter to run the code !!!!


Happy Hacking !!!!!!!

Related Entries:
Python3 ZWJ and Malayalam; some doubts
Python3 is wonderful
Installing PyLucene 3.x in GNU\Linux
New book in 'Head First' series with python
Graphical works with NLTK
 Permalink

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
Python3 is wonderful
Installing PyLucene 3.x in GNU\Linux
New book in 'Head First' series with python
Graphical works with NLTK
Comments (1)  Permalink

Python3 is wonderful


See the below given Python code. What do you think!! will it be executed without throwing errors or not?

####Code begin#####################
    import sys

    def പണിയെടുക്കൂ ( പാഠം):
        for വരി in പാഠം:
            print( വരി )


    വരവ് = sys.argv[1]

    മൊത്തം = open(വരവ്,'r').readlines()

    പണിയെടുക്കൂ(മൊത്തം)

######## Code End ######################

Don't scratch your head it will. If you use Python3 for running the code.

Save the code as test.py. Install Python3 . Run the program as python3 test.py <your file>

I just saw some new Python documentation for Python3 with some similar examples. Thanks to Santhosh Thottingal SMC for pointing the link. Then I decided to experiment with it.

Wow great in Python3 you can declare variable names function names in your local language. But you wont get the Python reserved words in in your language. I think Python is the first programming language which provides such a great facility.


Related Entries:
Again Python programming in Malayalam
Python3 ZWJ and Malayalam; some doubts
Installing PyLucene 3.x in GNU\Linux
New book in 'Head First' series with python
Graphical works with NLTK
Comments (4)  Permalink
1-3/3