need some regular expression help

Fredrik Lundh fredrik at
Sun Oct 8 12:15:51 CEST 2006

bearophileHUGS at wrote:

 > The dict solution looks better, but this may be faster:

it's slightly faster, but both your alternatives are about 10x slower 
than a straightforward:

def balanced(txt):
     return txt.count("(") == txt.count(")")


More information about the Python-list mailing list