>>> s = "((self start < self stop and self step > 0) or (self start > self stop and self step < 0))"
>>> s.count("("), s.count(")")
(3, 3)
>>> x = tokenize(s)
>>> x
'( ( self start < self stop ) and self step > 0 ) or ( self start > self stop ) and self step < 0 ) )'
>>> x.count("("), x.count(")")
(3, 5)
>>>