reading a line in file

Shawn Milochik Shawn at Milochik.com
Mon Aug 20 22:35:33 CEST 2007


Although you're technically correct, I think there's a knee-jerk
anti-regex reaction, citing the meaningless overhead. If you're
running many thousands of records or something then it becomes a small
issue compared to a replace statement or something. But in most cases
it makes no difference at all.

Run the example script both ways and I'm sure there will be no
difference, and I prefer a clear regex to a convoluted (in my opinion)
substring call.

In any case, it's a preference, and I have never seen anything which
convinced me that one should avoid regexes at all costs unless there's
no other way to do it.

And the comment about solving a problem by using regular expressions
creating another problem is just asinine.  Like so many other things,
it's often repeated without any thought about whether it is true in
general, much less in the situation in question.



More information about the Python-list mailing list