On Monday 21 November 2016 18:39, Jussi Piitulainen wrote: > Steven D'Aprano writes: [...] >> It's not awful, but I don't really like the look of all those >> try...except blocks. Is there something cleaner I can do, or do I just >> have to suck it up? > > Have the exception objects carry the message and the exit code? > > try: > begin() > cur = get_cur() > result = process(cur) > print(result) > cleanup() > except (BeginError, FooError, BarError, BazError) as exn: > print("Steven's script:", message(exn)) > sys.exit(code(exn))
Oooh, nice! -- Steven 299792.458 km/s — not just a good idea, it’s the law! -- https://mail.python.org/mailman/listinfo/python-list