Python

Comparison of ruby and python line by line (2/3)

In the first part of this series, you see how ruby and python retrieve data from given URL and then parse the results using regular expression. In part two, the code is extended to query prices from  through .

  1. Specify executable
    Ruby
    #!/usr/bin/ruby
    Python
    #!/usr/bin/python
  2. Import modules
    Ruby
    require ’net/http’  

Comparison of ruby and python line by line (1/3)

According to an article in Linux Journal #144Reuven M. Lerner demonstrated how to extend web services using other web services in Ruby. This article is very interesting and I love it so much even it is Ruby. I don’t have much experience in Ruby so I wonder how it could be implemented in Python. That’s the point drived me to post this blog. The original article shown 3 short programs which query prices by given ISBN from Skokie Public Library and . The first one is just very simple and short program for searching ISBN in Skokie.

How to read non-English character in mailman archives using Python

I was asked to help reading e-mail with TIS-620 encoding, Thai, archived by Mailman in HTML format. Since Thai characters are above ascii range, Mailman changed all Thai characters into ascii character by running escape entity function. For example, A could be encoded to A. That means all Thai characters were converted to € - ÿ, roughly. Both IE and Firefox will display these entities in latin1 encoding no matter what I forced, e.g., TIS-620.

Fortunately, Python helps me in just a few line of code. See below.

import re
s = "ÊØ¡ÃÕ"  

BTQueue 0.1.0 433

Welcome back to the text mode. BTQueue 0.1.0 has been released with build 433. In this version, you don’t need to worry about incorrect filename encoding. Since some torrent maker softwares do not encode filename in UTF-8 as specified clearly in the standard specification, the earlier version of BTQueue created unreadable filenames. This problem is gone forever, you can specify a list of possible encodings to try. In case of you don’t provide the correct encoding, the original filename will be used instead of scrambled one. This global preference is in policy.conf.

default_encoding = shift-jis,tis-620

Web Framework Statistics

This week could be the Web Framework week here. I have just found a good statistics regarding web framework. The first one is about Python Web Framework comparing to others. Arggg. There are so many frameworks for Python. Zope is the most popular one. The second is Python Template Engine Statistics. Zope is the first one again. And the last one, Programming Language Statistics, Java is the first and Python is the 7th.

Web Framework for Guido van Rossum

As you might know, Guido is spending 50% of his time on Python at Google in Silicon Valley. However, Python is not the main language there. Fortunately, it is the 3rd after C++ and Java. Not too bad. Well, his starter project at Google was to develop an web-based internal tools for Google developers. Google has a ton of reusable web server code for large scale servers, anyway, they are overkill in that project and it’s all C++. He was looking for a good web framework. Actually, he was looking for what it should be. During the research, he found and tried Django, Ruby on Rails, Quixote, Nevow, and more. He concluded as the word No XML.