cascading python executions only if return code is 0
Roy Smith
roy at panix.com
Sun Dec 22 23:57:29 EST 2013
In article <52b7a0e4$0$29994$c3e8da3$5496439d at news.astraweb.com>,
Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:
> Anyway, I may be completely misinterpreting what I'm reading. Perhaps the
> assertion is checking a function invariant ("one of the strategies will
> always succeed") in which case you're doing it exactly right and I should
> shut up now :-)
Yes :-)
More specifically, the assertion exception will get caught way up in
some django middleware which will log a stack trace and return a HTTP
50-something. This will typically be followed by somebody like me
noticing the stack dump and trying to figure out WTF happened.
Assertions are great tools. People should use them more often. In a
sense, they're executable comments. They're a programmer's way of
standing on a hilltop and shouting to all the world, "I swear to you,
this is true. There may be a gazillion lines of code out there and
GBytes of program state, but right here, right now, within this circle
I've drawn in the sand, I know this to be true, and you can depend on
that. You can make it part of the foundation on which you begin to
reason about program behavior. Furthermore, if it turns out not to be
true, you don't have to worry about figuring out who's fault it is. I
hereby declare that it's my fault".
More information about the Python-list
mailing list