Saturday, October 11, 2008

New Release of Python 2.6

A new version of Python, version 2.6 has been released.

This version contains recent addition to the incoming Python 3.0 that doesn't break the current 2.x version's code. As we know, Python 3.0 was designed to break compatibility of 2.x code. Some changes and additions to the 3.0 that is not breaking the 2.x is backported into this 2.6 release.

New modules added to the standard library: multiprocessing, json.

Look at the website: http://www.python.org/download/releases/2.6/

Thursday, September 18, 2008

SCons in Ubuntu Linux box

After fixing the annoying varnish installation problem, I could proceed with installation of SCons in my Ubuntu box.
$ sudo apt-get install scons

Then I created the same SConstruct file, with content:

Program('hello.c')

Invoke SCons:

$ scons




scons: Reading SConscript files ...

scons: done reading SConscript files.

scons: Building targets ...

gcc -o hello.o -c hello.c

gcc -o hello hello.o

scons: done building targets.

Invoke the executable binary:



$ ./hello




hello, world!

It really works as advertised! Excellent!


Wednesday, September 17, 2008

SCons 1.0.1: Python Based Multiplatform Builder Application

I was looking for a way to build application in a Maven  way, but which works beyond Java environment. I know that Maven 2 will somehow able to compile other source code such as C/C++ using some of the plugins. The reason I look for another tools because I might want to maintain my Python code as well.
Google search produced this SCons from Tigris. I downloaded  the version 1.0.1 and try to make a working instance of it.

I downloaded the zip from here, and the installation is straightforward if you already have a Python 2.5.2 installation.

python setup.py install

Voila. It works!

I ran the sample on my Windows machine, create a hello.c code.

int main() {

printf("Hello, world!");

}

Make a SConstruct file containing:

Program('hello.c')

It works as advertised! It invoked the Microsoft Visual C++ Express 8.0 on my machine.

Apart of it, it also produce a byproduct file: .sconsign.dblite of size less than 2k. I guess this is some kind of checksum to check whether the latest build is still up to date.

I will try it again in my VirtualBox Ubuntu machine.

 

Wednesday, September 10, 2008

Python on Windows: A Simple Perfect Pitch Trainer

These few days I have been playing around with Python, in part due to necessity to create a fast and easily modifiable web test client, and in part to fulfill my craving to learn new things.

According to the definition in wikipedia: 
Perfect Pitch is the ability of certain people to identify or recreate musical note without the benefit of known reference.

It means that you can pinpoint certain frequency (or its multiplication) without having external reference, your reference is built in internally. Say, you can pinpoint one note: A (440Hz).

Then if you have the ability to recognize relative pitch, then you will be able to construct any other note from that reference.

For those who wants to train his ear to gain perfect pitch, here is a simple script to train your ears in Python (sorry, Windows platform only...):

import winsound 

while(True):
. . winsound.Beep(440, 400)
. .
time.sleep(10)

This script will play the 'a' tone every 10 seconds for 400 milliseconds. Enough to pester your ears, and hopefully it will keep haunting your ears long after you have not put your earphones on. Human brains tend to interpolate and extrapolate, so hopefully your under conscious mind will replay the note over and over again.

Saturday, July 21, 2007

My Last Day,John Stovall, Python, WLST and Jython technology...

Yesterday supposed to be my last day @work. But somehow I must come again on Monday, and reschedule my flight to Batam to Tuesday. Moving to different kind of industry, but still in the same JEE/WebLogic/Solaris/Oracle path. Just a bit apart from the telco industry.

Lately I wasn't able to update this blog because at client office, they block the blog sites. Now, after being freed now I can start updating this blog again.

After accidentally meeting with John Stovall while at Changi Airport, I got enticed to learn more and more about Python, and Jython, its Java porting. First time I met John when I came to JaMU, December 2006. I was presenting Maven 2 technology, and each of the attendees were asked to introduce themselves. You can't miss noticing that big John. We happened to be in the same airplane, and after arrived at Changi airport, I began to recover his name, I called him, "Mr. Stovall", and then he began noticing an acquaintance. He's on the way to Amsterdam, to attend a Python meeting. He began preaching the beauty of Python, the philosophy behind it: "there should be one best way to do it...". I was also realizing that the reason why Guido von Rossum moved to Google was because of almost the entire Google site is based on Python.

I told John that I was using some Jython script because it is part of the WebLogic Scripting Tool (WLST). I learned a lot on it because some of my tasks while at Ericsson's project at Cyberjaya, was to create a automatic installation, deployment and setting tools. I found out that the best way to do it is through WLST. The older method wlshell still works, but using WLST, you could have access to a broader range of futures, both offline and online (requires a running WebLogic instance).

After returning to my regular tasks at Jakarta, I began downloading latest version of Jython. Before that, I have tried one of the scripting languages that has catch up the wave and has been ported to Java: JRuby. I also tried the scripting language made specially for Java: Groovy.

I began to fall in love working with Jython. You can utilize Java classes. The scripting language is close to the functional language I've been using a lot: Gofer+, a derivation of Haskell. Prof. Wishnu Prasetya taught us Data Structure and Algorithms using that functional language. Prof Mia Indika also taught the functional programming using the Haskell language. Python, er, Jython scripting more or less resemble that of Haskell. Sorry, for most of you who learned functional programming through typing lots of Irritating Parentheses (LISP). Though I also used Scheme when learning functional programming, later I mostly used the Gofer+/Haskell family of language.

Python also supports closure, so there is no point that Ruby is better. It only has Rails that makes it famous. I know when I learn Jython in depth, this is two fold, I could create better WLST scripts for WebLogic automatic deployments and configurations, and also be able to do OOP scripting for fast prototyping. I try to construct a script to test Hibernate DAOs and Managers. I will share some of these scripts when have more time to write it.