Next / Previous / Contents / Shipman's homepage

6.18. upcaseTokens(): Uppercasing 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 uppercase.

>>> sameName = pp.Word(pp.alphas)
>>> print sameName.parseString('SpringSurprise')
['SpringSurprise']
>>> upperName = pp.Word(pp.alphas).setParseAction(pp.upcaseTokens)
>>> print upperName.parseString('SpringSurprise')
['SPRINGSURPRISE']