reading Unix mailbox

Alessio Pace puccio_13 at
Wed Apr 16 16:49:36 CEST 2003

> I seem to rememeber that a recent version (probably 2.2) modified the
> mailbox objects so you could provide an optional (callable) factory
> argument when creating them, and this would then be called when the
> mailbox instance needed to create a message. The default is
> rfc822.Message, hence the behavior you are seeing.
> Does this help any?

Yes, almost..I tried with this simple:

import email.Message
import mailbox

mbox_file = file('../spam1.txt')
mbox_obj = mailbox.PortableUnixMailbox(mbox_file, email.Message)
msg =           # <-----what's wrong with this??

But I got:

Traceback (most recent call last):
  File "", line 6, in ?
    msg =
  File "/usr/lib/python2.3/", line 35, in next
    return self.factory(_Subfile(self.fp, start, stop))
TypeError: 'module' object is not callable

I am not a Python guru as you see...

> regards
> --
> Steve Holden                        
> How lucky am I?
> Python Web Programming       

Alessio Pace

More information about the Python-list mailing list