cascading python executions only if return code is 0

Roy Smith roy at panix.com
Tue Dec 24 04:58:59 CET 2013


In article <52b90263$0$30003$c3e8da3$5496439d at news.astraweb.com>,
 Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:

> Roy Smith wrote:
> 
> > So, here's the deeper question.  Is your issue strictly that -O elides
> > assert statements?  That's a purely mechanical issue that could be
> > solved by using the rather more verbose:
> > 
> > if not condition:
> >     raise AssertionError("....")
> > 
> > Would you feel differently then?
> 
> 
> Not quite. As I said in my initial rant, there's also the issue of using an
> appropriate exception.
> [...]
> If I think that the test is checking an internal invariant, assert is okay,
> if not, it isn't.

Well, in this case, that's what it's doing, so I guess I'm good :-)



More information about the Python-list mailing list