[Nolug] Python Line Noise

From: Mark A. Hershberger <mah_at_everybody.org>
Date: Sun, 13 Jul 2003 16:20:05 -0500
Message-ID: <87k7am6s56.fsf@weblog.localhost>

Perl gets flack because it is such a good language for managing and
using regular expressions. But, the reality is that anyone who uses
regular expressions will write code that some will use the pejorative
"line noise" against.

To drive the point home, look up "python one liner" on Google. The
first hit will contain this gem:

  [dict(re.compile('(?s)([^\n:]+): (.*?)(?=\n[^ \t]|\Z)').findall(item))
     for item in s.split('\n\n')]

Looks like line noise to me!

And, yes, Perl's implicit variables and use of RE in the language core
make the equivalent slightly shorter:

  [{/(?s)([^\n:]+): (.*?)(?=\n[^ \t]|\Z)/g}
    for split("\n\n")]

Note, though, that the line-noise portion of the code is practically
identical.

Earlier I said that REs were a little language that you could use in
lots of places. I think the above example shows the truth of this
statement. Don't let people scare you off of them. Don't be scared
by them. Learn them and love them.

Mark.
___________________
Nolug mailing list
nolug@nolug.org
Received on 07/13/03

This archive was generated by hypermail 2.2.0 : 12/19/08 EST