Why are String Formatted Queries Considered So Magical?

Jorgen Grahn grahn+nntp at snipabacken.se
Thu Jul 1 02:58:38 EDT 2010


On Wed, 2010-06-30, Steven D'Aprano wrote:
> On Wed, 30 Jun 2010 14:14:38 +0000, Jorgen Grahn wrote:
>
>> On Tue, 2010-06-29, Stephen Hansen wrote:
>>> On 6/29/10 5:41 AM, Roy Smith wrote:
>>>> Nobody<nobody at nowhere.com>  wrote:
>>>>
>>>>>> And what about regular expressions?
>>>>>
>>>>> What about them? As the saying goes:
>>>>>
>>>>> 	Some people, when confronted with a problem, think "I know, I'll 
>>>>>    use regular expressions." Now they have two problems.
>>>>
>>>> That's silly.  RE is a good tool.  Like all good tools, it is the
>>>> right tool for some jobs and the wrong tool for others.
>>>
>>> There's nothing silly about it.
>>>
>>> It is an exaggeration though: but it does represent a good thing to
>>> keep in mind.
>> 
>> Not an exaggeration: it's an absolute. It literally says that any time
>> you try to solve a problem with a regex, (A) it won't solve the problem
>> and (B) it will in itself become a problem.  And it doesn't tell you
>> why: you're supposed to accept or reject this without thinking.
>
> It's a *two sentence* summary, not a reasoned and nuanced essay on the 
> pros and cons for REs.

Well, perhaps you cannot say anything useful about REs in general in
two sentences, and should use either more words, or not say anything
at all.

The way it was used in the quoted text above is one example of what I
mean. (Unless other details have been trimmed -- I can't check right
now.) If he meant to say "REs aren't really a good solution for this
kind of problem, even though they look tempting", then he should have
said that.

> Sheesh, I can just imagine you as a child, arguing with your teacher on 
> being told not to run with scissors -- "but teacher, there may be 
> circumstances where running with scissors is the right thing to do, you 
> are guilty of over-simplifying a complex topic into a single simplified 
> sound-byte, instead of providing a detailed, rich heuristic for analysing 
> each and every situation in full before making the decision whether or 
> not to run with scissors".

When I was a child I expected that kind of argumentation from adults.
I expect something more as an adult.

/Jorgen

-- 
  // Jorgen Grahn <grahn@  Oo  o.   .  .
\X/     snipabacken.se>   O  o   .



More information about the Python-list mailing list