Rewrite python functionality.