trying to match a string

Fredrik Lundh fredrik at pythonware.com
Mon Jul 21 06:04:39 EDT 2008


oj wrote:

> Fine, this works, although match instead of search blah blah blah as
> has already been mentioned. I still think searching for one invalid
> character is more elegant then trying to match the entire string, but
> that's just personal preference, I guess.

The drawback is that it's a lot easier to mess up the edge cases if you 
do that (as this thread has shown).  The small speedup you get in 
typical cases is quickly offset by extra debugging/testing time (or, for 
that matter, arguing with c.l.py:ers over more or less contrived ways to 
interpret the original post).

Guess it's up to personal preferences for how to best help others. 
Unless the OP explicitly asks for something else, I prefer to use simple 
and straight-forward solutions with reasonable execution behaviour over 
clever tricks or odd-ball solutions; it's not a JAPH contest, after all.

</F>




More information about the Python-list mailing list