python script to rewrte history