def explain(simple_string, output): pattern = simple_string.character_pattern if len(pattern) == 1: if letters.match(pattern): output.the_letter() elif digits.match(pattern): output.the_digit() else: output.the_single_character() else: output.the_string() output.string(pattern)
def explain(single_character, output): if single_character.character_pattern == ' ': output.a_space() else: if letters.match(single_character.character_pattern): output.the_letter() elif digits.match(single_character.character_pattern): output.the_number() else: output.the_single_character() output.string(single_character.character_pattern) super(Group.SingleCharacter, single_character).explain(output)