make python cleaner

We can re-use code.