Why are String Formatted Queries Considered So Magical?

Terry Reedy tjreedy at udel.edu
Wed Jun 30 12:56:48 EDT 2010


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.

-- 
Terry Jan Reedy




More information about the Python-list mailing list