ANN: pyparsing 1.4.11 released
bearophileHUGS at lycos.com
bearophileHUGS at lycos.com
Mon Feb 11 04:44:37 EST 2008
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
More information about the Python-list
mailing list