Rewriting things in python