On Fri, Aug 7, 2020 at 11:32 AM Alex Hall <alex.moj...@gmail.com> wrote:
> > def not_valid(instance, schema): > >> > try: >> > return validate(instance, schema) >> > except ValidationError as err: >> > return str(err) > > > David, your example involves capturing the exception which was deferred in > the PEP: > https://www.python.org/dev/peps/pep-0463/#capturing-the-exception-object > It does, I recognize that. If I had the "exception ternary" that didn't capture the exception, I'd probably just evaluate to a True instead in the exception case... then go back to revalidate manually only in the unexpected case of validity failing. Of course, if some nice looking syntax did both, so much the better. Even the simpler form would have helped me though. I also know it is better in my example to return the exception object itself rather than just its stringification. If I were publishing my API more widely, rather than the internal use I had, I would have done that. -- The dead increasingly dominate and strangle both the living and the not-yet born. Vampiric capital and undead corporate persons abuse the lives and control the thoughts of homo faber. Ideas, once born, become abortifacients against new conceptions.
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/WSRJECQ3C6PIEBFWNQGKSLVPBLRO2TXM/ Code of Conduct: http://python.org/psf/codeofconduct/