Why are String Formatted Queries Considered So Magical?

Ethan Furman ethan at stoneleaf.us
Wed Jun 30 13:38:11 EDT 2010


Terry Reedy wrote:
> On 6/30/2010 8:22 AM, Nobody wrote:
> 
>>> I've noticed over the years a significant anti-RE sentiment in the
>>> Python community.
>>
>> IMHO, the sentiment isn't so much against REs per se, but against
>> excessive or inappropriate use. Apart from making it easy to write
>> illegible code, they also make it easy to write code that "mostly sort-of
>> works" but somewhat harder to write code which is actually correct.
>>
>> It doesn't help that questions on REs often start out by stating a 
>> problem
>> for which REs are inappropriate, e.g. parsing a context-free (or higher)
>> language, and in the same sentence indicate the the poster is already
>> predisposed to using REs.
> 
> They also often start with a problem that is 'sub-relational-grammar' 
> and easily solved with string methods, and again the OP proposes to use 
> the overkill of REs. In other words, people ask "How do I do this with 
> an RE" rather than "What tool should I use for this, and how".
> 
> If people asked "How do I push a pin into a corkboard with a (standard) 
> hammer" or "How do I break up a concrete sidewalk with a (standard) 
> hammer), it would not be 'anti-hammer sentiment' to suggest another 
> tool, like pliers or a jackhammer.

I took the time to learn REs about a year ago.  It was well worth it, 
even though I've only used REs a handful of times since, because when 
you need them there is no good substitute.  But when you don't, there 
are plenty.  ;)

~Ethan~




More information about the Python-list mailing list