def map_input(data, tables=None):
 result = []
 for char in data:
  replacement = None
  for mapping in tables:
   replacement = mapping(char)
   if (replacement is not None):
    break
  if (replacement is None):
   replacement = char
  result.append(replacement)
 return u''.join(result)

def map_input ( data , tables = None ) : result = [ ] for char in data : replacement = None for mapping in tables : replacement = mapping ( char ) if ( replacement is not None ) : break if ( replacement is None ) : replacement = char result . append ( replacement ) return u'' . join ( result )
each character in the input stream must be checked against a mapping table .