try: eval('importer exporter... really long matches') except SyntaxError: print("nothing to see here") finally: print("all done here") raise