Comparison with False - something I don't understand

Mark Wooding mdw at distorted.org.uk
Wed Dec 8 15:48:57 EST 2010


"OKB (not okblacke)" <brenNOSPAMbarn at NObrenSPAMbarn.net> writes:

>     	This is an interesting setup, but I'm not sure I see why you need 
> it.  If you know that, in a particular context, you want toy(x, 0) to 
> result in 42 instead of ZeroDivisionError, 

... and that's the point.  You don't know whether you'll need it at the
call site.  Something further up has decided that, in its context, 42
shall be the magic value returned.  In some other context, there
shouldn't be a magic value, and the exception should terminate the
program.

My toy example was just that: a minimal example showing the machinery in
action.  The value of separating out exception handling like this is
only apparent if there's a fair amount of code in between the policy
(`return 42') and the site where the exception is signalled.

Small examples of powerful abstractions aren't very convincing: a small
example trivially doesn't require powerful abstraction.  Sorry.

-- [mdw]



More information about the Python-list mailing list