Why are String Formatted Queries Considered So Magical?

Jorgen Grahn grahn+nntp at snipabacken.se
Wed Jun 30 10:14:38 EDT 2010


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.

How can that be a good thing to keep in mind?

I wouldn't normally be annoyed by the quote, but it is thrown around a
lot in various places, not just here.

> Yes, re is a tool -- and a useful one at that. But its also a tool which 
> /seems/ like an omnitool capable of tackling everything.

That's more like my attitude towards them.

/Jorgen

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



More information about the Python-list mailing list