[Tutor] Regex's and "best practice"

Alan Gauld alan.gauld at blueyonder.co.uk
Sun Nov 23 23:59:03 EST 2003


> I wrote the original script back in '86 on Perl 4.  I don't
think there
> were any public mail libraries (modules didn't exist with Perl
4) at the
> time, or I'd have just taken that approach with the Perl script
as well.

I assume you mean '96? Perl wasn't around in 86, let alone Perl
4.
And in '96 Python already had a basic email handling
capability... :-)
Batteries included etc.

> But let's drop down a level and say I'm writing a mailbox
module.  I'd
> probably still be using regexes, because trying to extract what
I'm
> looking for without them would be rather tedious.

Probably, although you might decide to do it in raw C...

:-)

But seriously the Pythonic route is to use the module not the
regex. regex's are used heavily in Perl because its so good at
them, but they are just not used as often in Python because
there is often an alternative approach, usually involving a
parsing module of some sort...

Alan G.
"When all you have is a hammer every problem looks like a nail."




More information about the Tutor mailing list