Simple Ajax with cherrypy and jQuery

All the cool kids these days are putting Ajax into their web applications. Ajax is great for when you want to update data on a page without reloading the entire page. Most of the Ajax tutorials use PHP, so I want to show here how easy it is to do Ajax with cherrpy.
Ajax stands for [...]

Easy SFTP uploading with paramiko

paramiko makes it so easy to use SFTP that it's hard to believe it's legal in this day and age. Command Line Warriors has a wonderful post showing how to use paramiko to do SFTP uploads/downloads.
In this post, I want to share a small helper module called sftp (zip file) (code in post below) that [...]

On rapid iteration

I think that one of the great strengths of interpreted languages like Python is the ability to iterate rapidly, due to the lack of a compilation step.
I've been reading Richard Feynmann's fascinating reminiscences in Surely You're Joking, Mr. Feynmann. The entire text is available online.
One passage that really struck me was where he described the [...]

mailer version 0.5 released

I've released version 0.5 of my mailer python module for sending emails. Thanks to a patch from Douglas Mayle, this version makes it possible to send HTML emails with attachments (previous versions only let you do one or the other).

Project homepage
pypi page

Converting kanji numbers to integers with Python

A question on StackOverflow about converting kanji numbers (e.g. "五十五") into integers in C++ got me interested in solving this using Python.
The result is my kanjinums module, with a function kanji2num that will convert a string containing a kanji num to a Python integer.
Download the source distribution (kanjinums-0.1.zip)
Download the Windows installer (kanjinums-0.1.win32.exe)
Download the unit tests [...]

Version 0.2 of mailer module released

I updated my mailer module (blogged about here) to version 0.2, and also uploaded it to pyPI.
Improvements in this version:

Default arguments in Message.__init__() method
Support for non-ascii charsets (in body and subject)
Support for Python 2.4

With the support for non-ascii encodings, you can now do this:

from mailer import Mailer
from mailer import Message
mailer = Mailer('smtp.example.com')
msg = Message(From="me@example.com", To="you@example.com")
msg.Subject [...]

The Adapter Pattern in Python

Interface mismatches are one of the banes of code reuse. You want to integrate component A and component B into your program, but component A expects a method called half_empty() while component B only has a method called half_full(). The Gang of Four (GoF) Adapter pattern is used to convert the interface of an object [...]

A module to send email simply in Python

Update: I've released version 0.3 of the mailer module. See the mailer home page for details and the latest version.
The email and smtplib modules in Python are very powerful, but they're also a bit complex when you just want to send an email.
I wrote the mailer module as a front end to these two modules, [...]

Conditional “tee” with Python

This post describes the conditional tee ("ctee") module I wrote to split a sequence into two generators, according to a filter function.
The problem
David Beazley has a great article about generator pipelining using Python. This is a technique for handling (potentially very large) streams of data in a flexible yet efficient way. As an example, here's [...]

Coming from C++/Java to Python should bend your mind

Coming from C++ or Java to Python should bend your mind. If it doesn't, then you haven't learned Python yet — you're just writing C++ or Java in Python.
If you only knew a statically typed and compiled language like C++ or Java before, and learning Python hasn't changed the way you think about programming, then [...]