pyparsing: parseString confusion

Peter Fein pfein at pobox.com
Fri Mar 11 13:24:13 EST 2005


My understanding of parseString seems flawed: I thought the grammar must
match the string in its entirety, based on the following from the howto:

"scanString allows you to scan through the input source string for
random matches, instead of exhaustively defining the grammar for the
entire source text (as would be required with parseString)"

However:
>>> from pyparsing import *
>>> alphas
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
>>> word=Word(alphas)
>>> word.parseString("foo888")
(['foo'], {})

I'd expect this to raise an exception.  What am I missing here?

-- 
Peter Fein                 pfein at pobox.com                 773-575-0694

Basically, if you're not a utopianist, you're a schmuck. -J. Feldman



More information about the Python-list mailing list