def tokenMap(func, *args):
 def pa(s, l, t):
  return [func(tokn, *args) for tokn in t]
 try:
  func_name = getattr(func, '__name__', getattr(func, '__class__').__name__)
 except Exception:
  func_name = str(func)
 pa.__name__ = func_name
 return pa

def tokenMap ( func , * args ) : def pa ( s , l , t ) : return [ func ( tokn , * args ) for tokn in t ] try : func_name = getattr ( func , '__name__' , getattr ( func , '__class__' ) . __name__ ) except Exception : func_name = str ( func ) pa . __name__ = func_name return pa
helper to define a parse action by mapping a function to all elements of a parseresults list .