It replaces any empty pairs of brackets until there are any of those left. If the initial expression is valid, all braces will be removed, therefore s will become an empty string and not s will evaluate to True; otherwise s will be non-enpmty and not s will evaluate to False.
Your explanation is extremely helpful, thank you and kudos for the clever solution.
It replaces any empty pairs of brackets until there are any of those left. If the initial expression is valid, all braces will be removed, therefore
s
will become an empty string andnot s
will evaluate toTrue
; otherwises
will be non-enpmty andnot s
will evaluate toFalse
.