Regular expressions

Antoon Pardon antoon.pardon at rece.vub.ac.be
Thu Nov 5 04:14:19 EST 2015


Op 05-11-15 om 01:33 schreef Chris Angelico:
> "I want to swim from Sydney to Los Angeles, but my gloves keep wearing
> out half way across the Pacific. How can I make my gloves strong
> enough to get me to LA?"
>
> Response 1: "If you use industrial-strength gloves and go via Papua
> New Guinea, you can double up the gloves and swim to LA."
>
> Response 2: "Swimming across the Pacific is a bad idea. Have you
> considered taking a boat or plane instead?"
>
> Which is the more helpful response? You can go ahead and assume the OP
> always knows best; I'm going to at least offer some alternatives.

What I see often enough doesn't look like offering an alternative but
more like strong argumentation against the direction the OP is going.

I have nothing against offering an alternative. There is the possibilty
that there are better methods to solve the original problem and there
is nothing wrong with suggesting this possibility.

But there is also the possibility that the direction the OP is heading
is the correct one, even if you can't see it. Take the original question
on how to recognize a line that ends with a '*' with a regular expression.

What almost noone seems to have considered is that the real problem might
have been more involved and an excellent example of a problem you can
solve with regular expressions but that there was this subproblem of recognizing
a '*' at the end of the line that was troublesome for the OP.

This is a possibility that is all too often ignored by the members on this
list. We advise people here to just show to most bare code that still 
shows the problem, yet we ignore that this effects the part of the problem we
get to see and often enough people then insist on a better alternative
to deal with the problem totally ignoring that this better alternative
may be totally useless in the original context.

-- 
Antoon Pardon




More information about the Python-list mailing list