[Tutor] Getting mail out of the box and into the email module

Magnus Lycka magnus@thinkware.se
Sat Feb 1 19:43:01 2003


At 22:12 2003-01-31 +0100, Scot Stevenson wrote:
> >>> import mailbox
> >>> import email
> >>> thebox = file("test.mbox", "r")
> >>> rawbox = mailbox.UnixMailbox(thebox, email.Message)
> >>> rawbox.next()
>Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "/usr/lib/python2.2/mailbox.py", line 34, in next
>     return self.factory(_Subfile(self.fp, start, stop))
>TypeError: 'module' object is not callable

Read the traceback carefully! Look at the last line here!

And then check your modules...
 >>> import email.Message
 >>> type(email.Message)
<type 'module'>
 >>> email.Message.Message
<class email.Message.Message at 0x01699280>

Maybe it works if you just hand over the *class*
email.Message.Message instead of the *module* email.Message!


-- 
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/  mailto:magnus@thinkware.se