attr = 'translated_parse' else: attr = 'untranslated_parse' if getattr(self, attr, None) is None: setattr(self, attr, make_parse_function(for_translation)) def parse(self, code): if self.for_translation: return self.translated_parse(code) else: return self.untranslated_parse(code) __secret_parser_state = __SecretParser() preparer.register(__secret_parser_state.setup) # This is the actual parse function that other modules can import from here. # (finally!) def parse(code): return __secret_parser_state.parse(code) def show_parse(code): """ NOT_RPYTHON: For testing/debugging use """ try: parse(code).view() except ParseError, e: print e.nice_error_message(source=code)