reading Unix mailbox

Alessio Pace puccio_13 at yahoo.it
Wed Apr 16 10:49:36 EDT 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 = mbox_obj.next()           # <-----what's wrong with this??

But I got:

Traceback (most recent call last):
  File "testMailBox.py", line 6, in ?
    msg = mbox_obj.next()
  File "/usr/lib/python2.3/mailbox.py", 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...
thanks


> 
> regards
> --
> Steve Holden                                  http://www.holdenweb.com/
> How lucky am I?      http://www.google.com/search?q=Steve+Holden&btnI=1
> Python Web Programming                 http://pydish.holdenweb.com/pwp/

-- 
bye
Alessio Pace




More information about the Python-list mailing list