Tuesday, December 16, 2008

Python 2.6 : ez_setup and setuptools, pylint on Windows

After i installed 2.6 i notice there is no setuptools windows installer in the python.org site.
So to manually install it you need to :-

1. Download this egg file :

2. Make sure u have download ez_setup.py from

3. ez_setup setuptools-0.6c9-py2.6.egg
PJ Eby :
Actually, you can just download the source, unzip it, and do "setup.py bdist_wininst" to build your own .exe installer.

Now you need to download the pylint for checking /integrating with ur ide.
And again, u notice that u will fail to get it installed via "easy_install pylint", so here
is the manual way.

(all the download links are at the upper right hand corner)

Download and unzip to all the folders, then goto each of them, common, astng, pylint and run :
python setup.py install

Case close.

.py association in Vista/Windows Missing

I was playing  with version 2.6 Python without uninstalling version 2.5. 
And for some reason i realize that when i execute a module without specifying the python.exe, the module could not get the arguments that was passed in.
For eg.

test.py argument1 argument 2
(argument1 and argument2 is missing from the sys.argv)

python test.py argument1 argument2 : works

Initially i tried "assoc .py" followed by "ftype Python.File" and the association was CORRECT!
It shows : Python.File="C:\Python26\python.exe" "%1" %*

Later i found out it was because there is still a registry key that is mapping wrongly.
Changing that registry key solves the problem.

Refer to the picture.

Sunday, November 2, 2008

Python Gotchas and Pitfalls for Windows Programmers

The no.1 pitfall i face is the "\r\n" that windows uses for its text "open" file where else in linux it will be "\n". 
Although this might seems obvious or easy to fix by using "open("xxxxx", mode="wb")" when writing a string to a file, its not as simple as it sounds.

This is because many of the functions that is supposed to be ported to Windows will failed to work, one example is the mbox and maildir, if you use the "import mailbox" and attempt to use maildir to store the files, even if you issue a "rb" on an eml, when you store it via :

    dest_mbox = mailbox.Maildir(path + folder, create=True)   
    msgdata = email.message_from_string(emailtext)        
    new_key = dest_mbox.add(msgdata)        
The stored eml message contains "\r\r\n". This will then be a problem when you try to parse it via the email module.

Who knows what other python provided modules works this way too...

Monday, August 11, 2008

Pylint On WingIDE Check on Save!

Now lets face it, for a data typeless language like python, its easy to get errors that other languages IDE would have picked up easily. For example, if you were to point "ooo = hellu()" and hellu() is actually a typo, it should have been "hello()". You wont get any error on the IDE until you run it.

This becomes pretty irritating when u have a number of these erorrs occuring when you are running your applications and you wished such flimsy bugs would have been picked by the IDE before you ever ran it.

Solution : Use Pylint.
Install it and goto "tools"->pylint and you will see a window on the right handside with "pylint" as the tab caption. (pls refer to other documentation on where to get and install pylint)

And what you need now is to have Pylint autocheck everytime u save a module so that all modules gets pre-checked and those irritating typos i mentioned earlier and other bugs will get caught.

Here is what you do, open up "editor-extensions.py" found in ur WingIDE installed directory under "scripts" (make a backup of this file first to somewhere else). Add the following lines at the end :-

def _connect_to_savepoint(doc):

def _on_savepoint(val):

if val == 0 :

# Get editor and do action
ed = wingapi.gApplication.GetActiveDocument()
if ed == None :


connect_id = doc.Connect('save-point', _on_savepoint)

def _savepointinit():
wingapi.gApplication.Connect('document-open', _connect_to_savepoint)
for doc in wingapi.gApplication.GetOpenDocuments():


And there you have it! Pylint total integration. Notice that if you open new modules and save it sometimes u get the "tried to execute an unavailable command .internal.gui.save". Just ignore this, the autosave in Pylint makes the IDE notice that you dont need to save the file again.

Thursday, August 7, 2008

Python : Working Directory Woes

Python has unittest that allows you to have a framework for testing your modules.
There is also nosetests. If you are using Wing IDE, there is a built in Test panel.
All is beautiful.

The problem is, if your project uses calls to "locate directory of where your script ran" you're in for a ride. Unlike windows api where u have a definite api to get this, the various ways in python to get the value resides in os.sys.path[0], sys.argv[0] and os.getcwd().

ALL the values you have seen will not get you the values you want, in unix when its run by using python or using the crond or when you run it from another script located elsewhere or in windows when you run it with "unittest, nosetests and even the Wing's Test panel" these values are going to give you a different result.

And then there is the py2exe ....which will give you yet another surprise as the path return is "\dist\library.zip"

Solution :

Temporarily put some guards for tests enviroment and use the following :-

def GetCurrentWorkingDir () :

if "Wing" in sys.argv[0] : return os.sys.path[0] + os.sep
if "nosetests" in sys.argv[0] : return os.sys.path[0] + os.sep

return os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]))) + os.sep

Thursday, July 31, 2008

Py2exe and email.generator, email.blah blah errors

Create this file :-

import email
msg = email.MIMEText.MIMEText("dsafdafdasfA")
print "ok"

Create setup.py like below :

from distutils.core import setup
import py2exe

Run python setup.py py2exe and you will get errors

The following modules appear to be missing['email.Generator', 'email.Iterators', 'email.Utils']

And your program will bombed out with errors like ""Import error : No module name text"

To solve this i just added " print self.__name__" under __init__.py of \email package.
And it seems the LazyImporter is confusing py2exe.

Solution ?

import email
import email.mime.text
import email.iterators
import email.generator
import email.utils

Thursday, July 10, 2008

Python : POP3 SSL Gmail Proxy

There was a friend of mine who went to Macau and his company uses Gmail for hosting corporate emails. He has a local mailserver that would want to download from this gmail and it doesnt support POP3 over SSL (port 995).

So once again Python comes to the rescue, 2 hours later, its done. A generic POP3SSL proxy that will allow any mailserver/client to collect mails from gmail via POP3SSL.

Just run : pop3ssl.exe host port (ur local ip and port that u want to use as proxy)
Example : pop3ssl 110 (or if ur mailserver is in the same machine, use another port)

Download it here : pop3ssl.zip

Note although its free for use, pls leave a comment here on how this program helped you.

Wednesday, July 9, 2008

Pythonist Rants

Its interesting to see how Pythonist does some stuffs and then suddenly you find that doing that in some other language wasn't a bad idea either ....and then...suddenly (again) it dawns on you that many things could be done in Python that is IMPOSSIBLE to duplicate exactly .

Lets say you have a vector in C++ that you need to remove an item if it fits a certain scenario.

The layman's way is to do the following in C++ (not using algorightm stl ;-))

vector::iterator ptr;
for (ptr = abc.begin(); ptr != abc.end(); ptr++)
if (*ptr == "red")
if (ptr == abc.end()) break;

This is one of the way Pythonist does it :-

for x in abc[:]: # this means makes a copy of abc
if x == "red" :

Yup, coming from C++, one's mentality one would wonder why we didnt use that similar method in Python in C++. However, this wouldn't work in C++ without futher modifications, this is because the "erase" is not taking a value but rather the iterator which means if you do this on the original vector but you passed in the iterator instance from the copy, it wouldn't work.

Then there is the story of smtpd.py. Its basically a smtp proxy/server skeleton that supports the basic commands. And how does one go and implement the "MAIL FROM", "RCPT TO", "DATA" method? The normal thinking would be to do a method/function for each of these commands and then there is the switch or if-else statement working on a read buffer.

How did smtpd.py do it?

method = getattr(self, 'smtp_' + command, None)
if not method:
self.push('502 Error: command "%s" not implemented' % command)

Introspection! It basically appends the command read and massaged from the buffer and append to the "smtp_" and invoke the method ....

Tuesday, July 8, 2008

Python fun project : MSN CHAT bot

I downloaded MSN-lib 3.6 from sourceforge and soon the naughty idea of linking this with Eliza
the therapist (joe, jeff , jez version of Eliza in python) cropped up almost instantly in my head.
So using a skeleton code of using MSN-lib i picked up from some forum, i did 1+ 1 = 2.

To make it realisic, i provide the "first msg" and the victim input before the bot takes full auto drive.

(All credits due to the original author and contributor to msnlib, eliza and related sources)

I must say i had a great time laughing over the chat logs as my friends and peers communicated with my chatbot. I made the program to log to some hardcoded directory of c:\msnbot since some sample codes is logging to some unix paths.

Well, if u need a break and a laugh, here is the chatbot and continue reading to find out how to configure it :-

Open the file : marbot.py, edit the values below and enter ur hotmail login and password.

m.email = "xxxx"
m.pwd = "xxxx"

Also change the name and nick to ur own :-

m.change_nick("-M- The future")

Ok, done now you are ready to go :-

python marbot.py

or just :


After running for a while it will ask 2 lines of input , the first line is the email id of the "victim" you intend to start a conversation with, the 2nd line is the first message you want to send to this person.

From then on, just watch and laugh as your friend communicate with Eliza. The logs are found in c:\msnbot (create this directory or unzip the files below to this directory)

Download the fun bot here

Monday, June 23, 2008

Visual C++ BrainBench Certification

I boldly went and took the Visual C++ BrainBench Certification without preparing myself in any refreshment task. I am very much caught in a surprise as i notice that the Visual C++ BrainBench actually means Windows programming in C++ , that includes OLE/COM, WndProc from scratch, device context and loads of other stuffs which frankly i have not been coding these natively but took the easy IDE way out.

It was a good test i must admit, it reveals to me how much i have taken for granted the advance tools and how much less i remembered of these subjects.

Here are the results anyway ( :-( scored within 3.x ...my python was 3.3, i was expecting a 4.x for a familiar language): BrainBench Visual C++ supervised :

Results for xxxxx

Test Takers Email: xxxxx

Date Taken: 23-Jun-2008
Test Event ID: ZC11178-CKQSJHX6

Overall Score: 3.56
Weights: 100% Visual C++
Elapsed time: 53 min 9 sec
Visual C++
Score 3.56
Percentile : Scored higher than 85% of previous examinees

Proficiency Level:
Advanced (Master)

Demonstrates a clear understanding of many advanced concepts within this topic. Appears capable of mentoring others on most projects in this area.

Strong Areas
General C++ Language
General Windows Programming

Weak Areas
None noted

Sunday, June 22, 2008

Python BrainBench Certification

I have been playing periodically with Python for a few months, i decided to take the BrainBench Certification was carried out by Deltaknot (http://www.deltaknot.com/). Brainbench by Deltaknot however appoints a supervisory staff to monitor the test taken so as to avoid where "few people answering a question"and other forms of "cheat".

Anyway, the test clearly shows some weakness in my understanding of Python, which will be the article for this blog.

But first, here is the result :-

Python 2.4 Assessment Report

Report Information
Examinee Name: (my name)
Date of Report: 6/23/2008
Prepared For: Deltaknot International Sdn Bhd
Prepared By: Brainbench

Assessment Results
Assessment Taken: Python 2.4
Date of Assessment: 6/23/2008
Overall Score: 3.32 (1.0 - 5.0, where 5 = best)
Worldwide Percentile: 67 (99 = highest)

Additional Score Data

Demonstrates a solid understanding of core concepts within this topic. Appears capable of working on most projects in this area with moderate assistance. May require some initial assistance with advanced concepts, however.

Standard Library

Weak Areas
Built-in Features

Ranking Information
.: 1 of 1 (99th Percentile)
.: 1 of 1 (99th Percentile)
.: 1 of 1 (99th Percentile)
Worldwide: 292 of 886 (67th Percentile)

First notice that my weakness as listed by BrainBench here are "classes and built-in features". Ironically after taking the test, i could identify these areas as well. Thiese are probably the same weaknesses that most seasoned programmers in other languages might encounter in the test.

This is because some of the ideas that we have learn from other languages, for eg, C++ naturally becomes the point of association and provides the learning platform when you learn other language. In my case, i skip most of the specific features of Python Classes since i believe i have a strong grasp of the C++ classes and thus didnt bother to pay much attention to it. The built-in features of Python are often viewed and subjected to my understanding of other languages and again which i ignored because i have never used them in practical programming.

For example the usage of : yield and function generators in python, now that is something you are not constantly exposed to in C++ and thus i have the tendency to ignore and skip over such topics, however in the test, these weaknesses are revealed.

This kind of remind me of Forbidden Kingdom, yes the girl is chun (Liu Yi Fei), but i am referring to the drunken master asking the disciple's cup to be emptied before he could teach him. There are some element of truths to this.

After coding in C# for the last few weeks, i found myself doing this in my C++ code :-

std::list listStrs = new std::list()

which is of course an error, since objects in C++ does not need to be "new" unless its a reference or pointer, but in both python and C#, you cannot instantiate any class member like a built in type.

Overall, i would say the BrainBench certification provides a good assessment since i agreed with the results and cheats are avoided due to supervision.

Thursday, June 12, 2008

Malaysia Downloads

Sometimes as programmers we need to download a large project from the internet for R&D or use. Often some of these are commercial frameworks or Open source projects.

Today i bought the Wing-ide 3.1.1 professional version and found the download speed from Malaysia is just 2.5kb and it will take 2 hours to download a 17 mb file.

So the trick is to use an alternate proxy site that has much faster connection to this download and at the same time a fast connection with Malaysia .

I tried : www.proxysite.org and it was fantastic. The download bumped from 2.5kb to 99kb/s.

The whole download took just 2 minutes. Now that is what i call productive bandwidth ;-)

Wednesday, May 14, 2008

RHB Internet Banking Programmers

There are sentiments that local programmers sucks. Sometimes its unavoidable that such
biased sentiments are expressed towards local talents and here is one such example.

I found out lately that i could not login to http://www.rhbbank.com.my/ to do my online banking, that means i have to queue up to pay for utilities and astro..(hehe)

The reason i could not login is diplayed on the page :

The following error has occurred.Result Code: 1
Result Message: *ERR-onlynum

This message implies 2 things :-

i. the programmers working on this project has implemented a check routine that
detects if your password is all "numbers" and to discourage you to continue using such "unsafe" practices it blatantly displays this message.

They even display on the login page that you should login to change ur password to alphanumeric for security reasons....but what they forgot was....

ii. the programmers working on this project was dumb enought to FORGET to test this system on users that have such passwords and the system did not allow the user to even login to change the password. So if you cannot LOGIN to the system, how in the world do they expect you to change ur password? This kind of logic i thought was something i witness during the first 2 years of my junior programming projects , but to see it happening on a PUBLIC website for a BANK is just unbelievable.

After a number of calls to the customer service, they said they need a WEEK to solve this problem on their IT dept. One wonders if a 5 minutes solution requires ONE week to solve and the very fact that they did not test the system for such cheap bugs is amazing.

If i was the Project director, i would have fired the team responsible and hired a whole bunch of new programmers , the chances of a team working on a Bank website to have such error is like hitting a lottery.

Tuesday, April 15, 2008

Linux is still dumb....inherited Shell genes

If you are working on both windows and linux at the same time, one of the first annoying thing that you will discover is that linux's shell (bash) is very unforgiving when it comes to "\r" or
carriage return or ctrl-ascii-13 ...whatever you call it.

When you use an ide to write some scripts and when you copied it to Linux, you get a really dumb message : "bad intepreter: No such file or directory" . It is really amazing at the time and age when software are supposed to be smarter and better, we have linux still stuck with dumb shells like bash who dont understand nor have to common sense to ignore "\r" as part of the new line. Although on windows if you open via notepad any text files written in unix, you will be similarly annoyed due to the missing \r, but i have yet to find a Windows program that is unable to process a file that is missing \r or created by unix text editors. Thus i can say Linux is still pretty much dumb due to the fact that it inherited some cow legacy while Windows have smartly sided with the users.

Meanwhile, you have to live with doing commands like this :

mv original.file backup.file; tr -d '\r' <> original.file

whenever you move some scripsts over from Windows.

Tuesday, April 8, 2008

IDE rules the day

I tried 2 Python IDE, Komodo 4.3 and Wing IDE 3.0.
Komodo has support for other languages like php and ruby while Wing IDE is on Python itself.

I must say Wing IDE's "intellisense" works much better than Komodo and the latter had a problem running on Vista with UAC on (even with admin rights) while Wing running under Admin was good.

However there are some things that both IDE could not address in Python coding that makes
the standard lower compared with VS 2005 IDE (we wont even talk on VS 2008).

When you key in python class for eg that inherits from another class, none of the ide manage to display the base class members methods when you are coding the new class. Maybe this is the problem with Python language itself make it much harder for the IDE to present the valid context for showing lists of members methods.

For eg if you have a base class "Dog" and it has 2 methods :

class Dog () :
def DigGround (self, where, depth) :

def Jump (self, objecttojump, height) :

class Basset (Dog) :
(expect no help here if you plan to override DigGround, you will need to look at the api reference as none of the IDEs could show you)

I know it a minor thing but if you are using Twisted for example, there are many instance where you would need to refer to the documentation for the apis if you plan overriding or calling some of these attributes which in the process is really frustrating. Unless you memorized stuffs like "one of the method you can override is def connectionMade(self): or def dataReceived (self, data)" it would be hard pressed to ask the IDE to show you these methods implemented at the those libraries you are using. (Twisted is becoming more of an essential library then option)

Updated : Incorrect, the Wing IDE source browser could show the base class methods even though the autocomplete does not provide much help. Definitely a good enuf reference to program productively in Python . Only on Wing IDE PRO. If you buy Wing IDE personal, too bad life goes on..

Ultimately the IDE makes a big difference in your productivity. Python is a very productive code however without an equivalent productive IDE, Windows Programmers will find VS offering an irreplaceable IDE to work with.

However, having said that, if you are into PHP and ruby as well, then there probably is no better ide than Komodo for "multi-open-source" language editor (apart from Eclipse which you need to download the plugins ). As for Wing IDE, it is still one of the best Python editor around, so if you are into serious Python (which i do hope to see more Windows commercial project on this), then its an excellent choice.

Sunday, March 30, 2008

C++ or Python

After playing with python and implemented it in a commercial product lately, i am quite happy with familiarity i have with the language now.

So the question is, will Python replace C++ in my new work? Unfortunately, i must say as long as i am in Windows, C++ is still one of the best language to use for shipping solid, tight and resource friendly code. I can't hire a team of C++ as easily as i can hire and train programmers in python and C#, the latter being a preference in Windows also.

So whats all these fuss of Python rocks etc?
Python does rocks, however one has to taken into consideration at the base level its still pretty much a bytecode interpreted language. C++ however gives you total power and its limited only by programmer's skill and knowledge.

In today's programming, one needs to be practical. If i need to hire good C++ programmers, it would take much effort and its nearly impossible to keep them. If their skills are amaturish we end up with a ton of bugs which needs time to debug and fix and like habits , some programmers takes a long time to fix their coding practice. This is where languages like C# and Python comes in, it makes forming a team fast, it lowers the penalty and possibility of bugs in programming (Python even enforces tabs and code readability to some extent).

Although there are success stories in Pyton, eg the bittorrrent, one must not forget the current popular bittorrent client is utorrrent, which i believe given the size, is probably written in C++. So how does a C++ product replace a Python product given that the Python product was already in the market lead?

I leave that question to you.

Wednesday, March 19, 2008

Cheap hacks

Yup, i dont like cheap hacks. I dont like the idea of parroting what the internet community proclaimed hackers has done and presenting it as though as one discover it.

Various security seminars held here in Malaysia consists of more than 90% security exploits that are nothing more that copy-cat / parrotting.

Most real exploits are discovered by real programmers, not hackers. Programmers who understand how the system works and why it would fail resulting in an exploit discovery, sometimes its discovered accidently.

The way some folks use the work "hack" you probably think these folks are hackers, in actual truth however, these folks are just wanna-be. Ask them to show you one original exploit that they discover themselves and you get a blank stare.

Do i hack? No, maybe just some games vs the computer which today are no longer needed due to built in cheat codes. Hacking should be reserved for breaking into security systems.

Just the other day i saw on CNN how some chinese teens contacted CNN and promised to reveal hacking information . While i pity the reporter since he has not much idea whats going on and seeing a "ping x.x.x.x" running in a cmd console seems to impart the "hacking" feel, i doubt those teens have anything solid. Later when CNN interview a guy from Verisign defense , he gently says something along the line of "i dont think those guys are in the echelon to do what they claimed... ". In reality many don't, many just want to project the cool impression that they hack, but they are just running some tools that they cut + paste from somewhere.

On that note :

Type ' OR ' , as the name and password, including the ' , and congratulations you just hacked RTM streaming. "Oh wow! new site hack, lets spread the word!!" <- exactly the kind of stuffs cheap trills are made of. SQL injection has been around for ages, no big deal, it will take less than 2 minutes to fix the site up. But these are the kind of demos you get by self proclaimed Malaysian hackers.

Thursday, March 13, 2008

Python Take III

These are my first 3 book on Python. Having read them from cover to cover.
The philosophy of Python makes all the difference here. It summarizes most of the tenets of programming as far as coding is concerned that i believe and practiced although mostly on other languages that i worked on...

If you start the Python intepreter and type "import this" you will get the following beautiful summary of what programming should be :-

The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

Monday, February 25, 2008

Python Take II


Here is the verdict. Python simply rocks.
I am going to move one of my project from C/C++ to full Python.

There are a few things that makes Python a real magnet to programmers like myself :-

i - enforcement of readability and tabbings
ii - unit testing is naturally the way of python, each module is developed and tested easily
iii - rapid development for "engine" type of development is fast
iv - superior basic types, like list, and dictionaries that are iterable
v - oreilly python books are all pink (hehhaha, no relevance to edison chen pink mac)
6 - calling C dlls is a walk in the park
7 - works on both windows and linux

I have 3 books in my collection now, Learning Python, Programming Python and Python Cookbook. The cookbook series is a must if you are moving to a new language and you are an experienced programmer. It beats scavaging the internet for junks codes written by amatures, cookbook codes on the other hand are of excellent quality.

Saturday, February 9, 2008

Python From a Newbie Perspective

The Python support for Win32 comes in the form of PyWin32.
However the documentation is very weak and lacks the standard that one normally feels when using products from "de" Giant software company. This is the difference between a product that is made by a company with $$$$ and one that is of voluntary work. No amount of voluntary work could compete with highly paid dedicated people that is assigned to a task.
(activepython on the other hand gives an overall much better starting point)

Although i have the utmost respect for the work done as an open source product and the maturity of python as a programming language, i do feel that such low quality documentations only deters new programmers from fully adopting Python, especially those that have tasted something better like Visual Studios.

Python has been around for nearly 17 years now, but C# has covered more mileage and devotees in a few years than Python.

Here are some sane arguments, as trivial as it is, i felt it is important and is a stumbling block to convert anyone who has been using MS products

Python documentation lacks examples
What better way for seasoned programmers to learn than to just take a peek at how a function
is used? The standard docs that comes with Python 2.5 lacks useful examples. You end up buying a book from Oreilly (Mark Lutz) or scavaging the internet. Alternatively fireup the interactive session and try.
The 2.5 documentation is however much better than the pythonwin documentation, the indexing itself proved to be different.
If you were to use the "index" on the chm file provided for pythonwin, be amazed that one keyword you will have say 10 listing and u have no idea which one is the full description.
Lets take a look at one simple example : DeviceIoControl (win32file, phyton Win)


string = DeviceIoControl(hFile, dwIoControlCode , data , readSize , ol )
Call DeviceIoControl
hFile : int
Handle to the file
dwIoControlCode : int
IOControl Code to use.
data : string
The data to write.
readSize : int
Size of the buffer to create for the read.
ol=None :
An overlapped structure

Any windows programmer knows that there is supposed to be 2 buffers in the original windows "DeviceIoControl" , one for read and the other for write. So even if PyWin decideds to make life easier by using some smart detection on the parameters and selecting to "return the read buffer" as a return value (string), you can see from the documentation above, no hints is given. One can only be left wondering what is "string" supposed to be, things like "hFile" :int is not a int handle but rather the PyHandle, again hardly mentioned. Examples for using these apis (not just this one) are as scarce as water in the desert.

* the activepython documentation was better since it merges all necessary documentation into one place, however pythonwin docs for win32 stuff still sucks.

* the string return value is the replacement for the read buffer. If the values were actually c-integer , well, you have to figure out how to convert the python string with raw data representing the c-integer into phyton int. Yeah, for seasoned pythoners working with w32, this might be easy, for new comers even with java, c++ or c# background, they would be more productive sticking with their proven tools.

Python has some unjustified oddities (noob bugs?)

x = 0

class Hello :
def __init__ (self) :
global x
x = 100
def __del__(self) :
global x
x = 0

def DoNothing() :
xyz = 100

a = Hello()
b = DoNothing()
print x


What do you think the result would be? Run on a python and see for yourself, then comment out "DoNothing" and run it again .
Bug? By george, this is already Version 2.5 and if the garbage collector is still buggy with something as simple as this.....

*** The activeState Python however does NOT have this bug!!

Python PyWin32 GUI needs refinement
The autocomplete feature for example will come as a shock to many VS users, instead of the
natural convenience of pressing "enter" to select the autocomplete listing, you need to press "tab". The logic behind "enter" is simple, your right hand is already bz with pressing the "up" and "down" arrows and it won't be doing anything else so using that same hand to press the "enter" key which is just above those arrow keys is fast and easy. Pressing "Tab" on the other hand requires your left hand to move from its natural typing position while the "right" hand which is stuck doing nothing at the arrow keys . I don't think this could be modifed from the config.cfg file for the keyboard layouts.

Its hard to explain but that is what ergonomics is all about, refinement over routine habits that yields comfort and productivity as the goal.

Somehow VS just got it right, even Eclipse misses a mark. For eg, using the php plugin to Eclipse, when you enter [', as a corrective fix to ur expression, the ide will rudely add in ']', without any smart detection that you are typing between the expressions (eg correcting _GLOBAL$(hello'])

When you add up all the "annoyances" in phyton ide, its obvious they need to learn from MS.
But...But...it is an excellent ide for free.

Python needs a proper image
You will likely see a lot of python related stuff using "snake" icons and images as though that was the real meaning of the language. Unfortunately its actually named after "monty python" a comedy show. On the other hand you have O'reilly, the most respected programming book publisher using all kinds of images for its Python books, ironically "Learning Python" uses a "mouse" as its front cover and pink color as the scheme.

Ok, maybe Python theme is a humorous one, but many programmers would prefer if their career and livehood tools are serious cause not everyone gets employed by Google or use programming for academic purposes. (if u can find a company in Malaysia or Sg that will hire you for using lisp and fortran, pls post a comment here, i need to know why some languages i considered "offline" are still commercially viable)

So what are you trying to say ...

So, does this mean that python sucks and we should avoid it?

I suggest you take up this language when you are on some vacation and see for yourself.
The language survived for many years and it does have some really fun and powerful factors
such as list, tuples and dictionary built in types and i love the fact that the tabs/whitespaces are enforced into the language itself.
The interactive session also makes learning fun and unlike the VS that we all "had to love", the size and implementation dont experience the same "bloat" that you get from .Net.
I must say its a very unique programming language that kept me sleepless for few days playing with it, the sheer fun and joy of learning a new language.
I do recommend that you use ActivePython and not python.org (See the bug above, tested on windows vista, python 2.5)

Tuesday, February 5, 2008

Wifi Hell and Acer 4520 (open suse 10.3)

Chinese New Year is just tomorrow and i was walking around tesco and i saw some really cheap notebooks, RM 2k for various brands. HPs. compaqs and Acers were the models displayed. The same offer you can find in Carrefour.

I notice it comes with "Linpus Linux", a fedora based linux that is shipped by a taiwan company and Acer is putting it in these low cost notebooks.

So i grabbed one since i am playing with phyton nowadays and i plan to have a dedicated Open Suse 10.3 instead of running it via my Vista vmware (ouch!). There is where the hell begins...

The Wifi wouldn't work and this is not some newbie problem. Although some manage to get it working perfectly on Mandriva and Ubuntu, it seems that the Wifi that comes with this ACER Aspire 4520 has a string of problem when it comes to getting it to work on 32 bit Open Suse.

The said wifi is Atheros Wifi.

The following are things that DON'T work :-

- using ndiswrapper and getting the Atheros wireless driver for XP
- acerpanam.com latest drivers and via ndiswrapper
- madwifi default packages and latest build (up to this blog entry, so feel free to try)
- any vista/xp driver attempting to be used via the ndiswrapper (ndisgtk + related stuff)

There was one Ubuntu forum that shows how this was done successfully on the Ubuntu, and somewhere else a guy in malaysia copied the instruction and posted it as his own...with no credits given. However, the exact steps doesnt work on Open Suse 10.3 even after i mapped the correct differences.

Finally 12 hours of non sleep attempt, here is your ANSWER :

1. Download the following files and transfer to ur linux via USB drive.



Read the How to Apply from here : http://madwifi.org/ticket/1679

2. Read the following and do :-

3. Run the "yast2 lan" or via ur yast2 (my computer, administrator setting) and set ur configuration from there, setting via the iwconfig etc won't work. After that use the icon on ur system tray and connect to ur SSID (router), re enter the WEP key if needed.

There. I just saved you 12 hours.

As for Nvidia drivers, just download http://www.nvidia.com/object/linux_display_ia32_169.09.html
and do the sh NVIDIA* instead of depending on the yast.

Monday, January 14, 2008

Kids Stuff - The ultimate in learning Programming

When i was in form2, the teacher gave all of us an assignment. Write a report of a survey of any topic . My particular group consist of 3 guys and we decided to do a survey on "What kind of boys you like to be your boyfriend". Yeah, seems like we were taking advantage of the teachers assignment to satisfy our curiousity. ;-)

My school back then was St.John Institution, a school that was the envy of many boys school, not because St.John has the best atheletes back then (even though we claimed we were) but because we were surrounded by girls school.

Just across the road we have Convent Bukit Nanas (aka the "classy" girls), not far away we have St.Mary Girls' School (aka the "best" choice) and down the road we have Bukit Bintang Girl School (aka the "naughty" girls who didnt make it to the other 2 schools).

The survey was completed in 3 days since the questions was circulated via the school buses that conveniently provides transportation for most of these schools. I was given the solemn task of compiling and making the results into a report.
But instead making it a dull and serious report, i used a format back then that got people laughing. I cut various pictures from magazines and drew baloon dialogue boxes to present the points. Most thought i would be given a stern warning from the English teacher, but instead she praised me for creativity.

Fast forward to my current time now..Welcome to the new school where programmers needs to learn many stuffs with minimum time. The Dummies line of books has been very successful so much so that you can find all kinds of topics in it and why was it successful? Because the presentation was clear, and people are tired of reading dull scholarly words.

Just the other day i got myself a book on "Head Rush" by Oreilly on certain programming topics. After reading it for 2 days, i conclude that this kind of format is one of the best books available today for learning IT .

If you are curious about certain programming topics, like Ajax, C# or Javascript, before you jump all over the net gobbling up every garbage you find and end up being half-cooked, I suggest you take up "Head Rush" line of books for the topic you are interested in.