Saturday, January 19, 2008

Python Interpreter in ROKR E2!

A few weeks ago, I decide to learn of a higher programming language, such as C++ or Python. Since C++ language need to be compiled before it can run, then I choose Python. Why? Because it easier to learn, easier to read, also it can run directly with the source and an object oriented programming too. Ah, one more, do you know that our E2 can be used as Python interpreter too? Interesting right? :)

First you will need Terminal Emulator installed in your phone and the Python itself. You can find both at my friend website e2mod.com. Installing Terminal Emulator is easy, I believe you can do it yourself. To use Python, you just need to copy the bin and lib folder at Python packages to SD root (/mmc/mmca1).

Second, start your Terminal Emulator and write "/mmc/mmca1/bin/python". The Python interpreter will be shown now! You can start writing now. See the screenshot below:
Snap
Notes: I renamed the ~/bin/python2.5 to ~/bin/python only. :)

Third, you also can run the Python script with the Terminal Emulator! Well, you can did it with telnet too or a script shell too. Unfortunately, Terminal Emulator didn't support many symbol, we can use only 4 symbol (-/.,) there! So we can't write "export PATH=$PATH:/mmc/mmca1/bin" (we don't have =, $ and : also we can't write in uppercase with Terminal Emulator!) that makes us can't call the Python script anywhere (it can, but will confusing). The best solution is place the Python script in /mmc/mmca1 then call it using "cd /mmc/mmca1" after that "bin/python (script name).py". Here is the example:

As you can see in example, I called the Python script in /mmc/mmca1/zzz.py which is a simple Python script to count down from 10 until 0.
Notes: See the error message after we call Python? I don't know why and don't understand what it means, but tell me if you know, ok?

Ah, BTW, you are better to use Telnet than Terminal Emulator, just in case that you are far away from your PC and want to create (or get an idea) script, you will thank to this tools (as I did). :) Enjoy programming!

1 comment:

Anonymous said...

Bigger font is better