Paul McGuire: > - Added '==' short-cut to see if a given string matches a > pyparsing expression. For instance, you can now write: > > integer = Word(nums) > if "123" == integer: > # do something > > print [ x for x in "123 234 asld".split() if x==integer ] > # prints ['123', '234']
Maybe you can use the "in" instead of "==", meaning that a certain string conforms to a certain pattern, that defines an implicit class of possibilities, so with the "in" you look if the string is present in that class of acceptable patterns, instead of being equal to that class. integers = Word(nums) if "123" in integers: # do something print [x for x in "123 234 asld".split() if x in integers] # prints ['123', '234'] Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list