Steven D'Aprano wrote:
> def rationalise_signs(s):
> while "++" in s or "+-" in s or "-+" in s or "--" in s:
> s = s.replace("++", "+")
> s = s.replace("--", "+")
> s = s.replace("+-", "-")
> s = s.replace("-+", "-")
> return sI assume it's faster to check the length of the string s after each iteration and compare it to the last iteration. When the string hasn't changed break out of the loop. -- http://mail.python.org/mailman/listinfo/python-list
