rewrite s.uniq using python