Ah, I had just made the same change!

from pyparsing import *

wrd = Word(alphas)
parenList = "(" + SkipTo(")") + ")"
brackList = "[" + SkipTo("]") + "]"
listExpr = ZeroOrMore( Combine( OneOrMore( parenList | brackList | wrd ) ) )

t = "a (b c) d [e f g] h i(j k) l [m n o]p q r[s] (t u)v(w) (x)(y)z"
print listExpr.parseString(t)


Gives:
['a', '(b c)', 'd', '[e f g]', 'h', 'i(j k)', 'l', '[m n o]p', 'q', 'r[s]',
'(t u)v(w)', '(x)(y)z']



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to