reading Unix mailbox

Alessio Pace puccio_13 at yahoo.it
Wed Apr 16 10:55:19 EDT 2003


> 
> 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

I solved putting as factory: email.message_from_file
Thanks again, it seems to be the solution I needed

-- 
bye
Alessio Pace




More information about the Python-list mailing list