Date: Mon, 24 Mar 2008 20:56:23 +0200 From: Giorgos Keramidas <keramida@ceid.upatras.gr> To: Robert Huff <roberthuff@rcn.com> Cc: questions@freebsd.org Subject: Email processing in Python (was: e-mail processing in C) Message-ID: <874paw3q94.fsf@kobe.laptop> In-Reply-To: <18407.62370.787768.503114@jerusalem.litteratus.org> (Robert Huff's message of "Mon, 24 Mar 2008 14:32:02 -0400") References: <18407.62370.787768.503114@jerusalem.litteratus.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 24 Mar 2008 14:32:02 -0400, Robert Huff <roberthuff@rcn.com> wrote: > I need to write a quick and not-too-dirty C program to process some > e-mail. (Including dealing with mbox files.) > > Is there a standard library to do this? Respectfully, No, there's no library for `email processing' in the C standard. You can probably find a lot of non-standard ones, by Googling however :) It's worth writing that plain C is the wrong language for this sort of thing, if you ask me. There are excellent high-level libraries in Perl, and Python to do this sort of thing. Email processing is going to require a log of string processing, and C is notoriously 'tricky' for this sort of thing. As an example of the expressiveness of using a higher level language, you can display the authors of all the messages in a UNIX mailbox with the following short Python script: import mailbox m = mailbox.mbox('/home/keramida/mbox') for message in m: author = m['from] print author This is not just a `readable pseudo-code-like example'. It's *real* Python code, that you can run _now_ in your Python shell. To perform a similar task in plain C you will need several dozens of lines of code, and it won't necessarily be as readable. It _may_ be faster, in some cases, but it will probably won't be as 'safe'.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?874paw3q94.fsf>