Next / Previous / Contents / Shipman's homepage

6.5. downcaseTokens(): Lowercasing parse action

If you use this function as a parse action, the effect will be that all the letters in the values that the parser returns in its ParseResults will be lowercase.

>>> sameName = pp.Word(pp.alphas)
>>> print sameName.parseString('SpringSurprise')
['SpringSurprise']
>>> lowerName = sameName.setParseAction(pp.downcaseTokens)
>>> print lowerName.parseString('SpringSurprise')
['springsurprise']