The Samurai Principle

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Wed Sep 8 16:26:34 CEST 2010


On Tue, 07 Sep 2010 20:38:14 -0700, Phlip wrote:

> On Sep 7, 5:51 pm, Terry Reedy <tjre... at udel.edu> wrote:
>> On 9/7/2010 2:53 PM, Phlip wrote:
>>
>> > They are for situations which the caller should care not to handle.
>>
>> Python is simply not designed that way. Exception raising and catching
>> is a common flow-control method in Python. If you cannot stand that,
>> Python is not for you.
> 
> While I'm at it, I'm going to log into comp.lang.java.misc and explain
> to everyone why static typing is overkill, and implementation
> inheritance is good for you.
> 
> Everyone gets defensive about the design flaws in their own language.
> But the django.db situation is not even a design flaw; just a
> misinterpretation of the Samurai Principle. int('yo') shall throw an
> exception, but a missing record could be the result you were looking
> for, so it's not exceptional.

I think you've misunderstood the meaning of "exception" if you think 
that. It doesn't mean "error". Nor does it mean "rare". (Although, given 
that exceptions in Python are expensive, one would hope they're not *too* 
common.)

The unexceptional case of looking up a record is to find it. That, after 
all, is the purpose of the lookup function -- to find the given record. 
That's what it is designed to do, and anything else is considered 
exceptional.

Whether the lookup function returns a special "not found" result, or 
raises an exception, or sets some magic global error code somewhere, it's 
still an exceptional case.


-- 
Steven



More information about the Python-list mailing list