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> -- http://mail.python.org/mailman/listinfo/python-list