[Python-ideas] New imaplib implementation for Python 3.2+ standard library

Maxim Khitrov max at mxcrypt.com
Mon Jul 25 20:16:35 CEST 2011


On Mon, Jul 25, 2011 at 12:46 PM, Bill Janssen <janssen at parc.com> wrote:
> Maxim Khitrov <max at mxcrypt.com> wrote:
>
>> The same repository also contains the library code and an example
>> script that you can run if you have access to an IMAP4 server:
>>
>> http://hg.mxcrypt.com/python/imaplib2/
>
> I took a look at this.  Nice work!  Impressive list of extensions
> implemented.

Thank you :)

> The first thing to ask is, does it pass the (minimal) test suite in
> Lib/test/test_imaplib.py?  Or is it too different?

Too different. Writing my own test suite is the next step. The library
already went through extensive testing on Gmail and MS Exchange
servers while I was developing my main project, but of course a good
set of unit tests is needed for long-term maintenance.

> The code seems to be not quite in compliance with PEP 8.  If you're
> aiming at the stdlib you should probably fix that.

Will do.

> I tend to think one of the larger missing pieces of imap4lib is the lack
> of a higher-level interface.  I've used imap4lib for a couple of
> projects, and I think that if I hadn't already had the experience of
> implementing my own IMAP server in Python, I wouldn't have done that;
> I'd have used a package like getmail instead.  There's a lot of
> experience with IMAP necessary to use imap4lib.

True, but that's the case with all low-level interfaces. Having used
imaplib for a while before deciding to write a replacement, I do think
that building a higher-level interface using my library is
significantly easier.

I'm not certain if that interface should be part of the library or a
separate module, similar to the relationship between zlib and gzip. I
think the latter makes more sense, because any serious IMAP4 client
will still need to descend to the protocol level.

> Looking at your example.py, that still seems to be the case.  One thing
> you might consider is implementing a subclass of "mailbox.Mailbox" which
> provides that missing higher-level interface to IMAP4.

I've never used the mailbox module before. It looks like it is aimed
primarily at working with local mail stores, no? I'm not sure if
that's the right interface to use over the network, but I understand
your point.

I'll try to write another class on top of my library with a much
simpler API for navigating through the mailbox hierarchy and working
with messages. Will upload it to the repository when it's ready.

- Max



More information about the Python-ideas mailing list