Before planning to write some odd Python scripts to remove duplicate lines from the log file you are analyzing, consider using uniq(1) :

cat my.log | uniq

Beats writing your own script, that’s for sure!