cascading python executions only if return code is 0
Ethan Furman
ethan at stoneleaf.us
Mon Dec 23 07:45:07 EST 2013
On 12/22/2013 08:57 PM, Roy Smith wrote:
> 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.
This is completely misusing what assertions are for. I hope this bit of middleware (or django itself) is very clear
about never running with assertions turned off.
> Assertions are great tools.
Only when used properly.
>People should use them more often.
I see them being (mis)used too much as it is.
>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,
Considering how easy it is to disable assertions, a circle in the sand is an amazingly appropriate metaphor. :)
--
~Ethan~
More information about the Python-list
mailing list