Short-circuit Logic

Roy Smith roy at panix.com
Fri May 31 09:20:02 EDT 2013


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

>     In an early talk Ken was explaining the advantages of tolerant
>     comparison. A member of the audience asked incredulously, 
>     “Surely you don’t mean that when A=B and B=C, A may not equal C?”
>     Without skipping a beat, Ken replied, “Any carpenter knows that!”
>     and went on to the next question. — Paul Berry

Any any good carpenter also knows it's better to copy than to measure.  
Let's say I have a door frame and I need to trim a door to fit it 
exactly.  I can do one of two things.

First, I could take out my tape measure and measure that the frame is 29 
and 11/32 inches wide.  Then, carry that tape measure to the door, 
measure off 29 and 11/32 inches, and make a mark.

Or, I could take a handy stick of wood which is 30-something inches 
long, lay it down at the bottom of the door frame with one end up snug 
against one side, and make a mark at the other side of the frame.  Then 
carry my stick to the door and keep trimming until it's the same width 
as the marked section on the stick.

Google for "story stick".

The tape measure is like digital floating point.  It introduces all 
sorts of ways for errors to creep in and people who care about getting 
doors to properly fit into door frames understand all that.



More information about the Python-list mailing list