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.