I initially did it the way you say, but it turns out not to be Python-2.4/5 compatible.