reading a line in file
Brian.McCann at viziant.net
Mon Aug 20 23:05:49 CEST 2007
what if I had a file
com.properties with the below line in it
If I needed to capture the value of everything separeted by a ":"
and asign each to a variable would regex be the right method to grab those?
From: python-list-bounces+brian.mccann=viziant.net at python.org on behalf of Shawn Milochik
Sent: Mon 8/20/2007 4:35 PM
To: python-list at python.org
Subject: Re: reading a line in file
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)
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list