python rewrite