PortableUnixMailbox problem
Joe Murray
jmurray at agyinc.com
Thu Jun 7 14:57:59 EDT 2001
Gustaf Liljegren wrote:
>
> Guess I don't understand how to use it, but I get this error when trying to
> use the new (2.1) PortableUnixMailbox class:
>
> E:\test>python pum.py
> Traceback (most recent call last):
> File "pum.py", line 4, in ?
> m = mb.next()
> File "e:\python\lib\mailbox.py", line 19, in next
> self.fp.seek(self.seekp)
> AttributeError: seek
>
> And my code:
>
> from mailbox import PortableUnixMailbox
>
> mb = PortableUnixMailbox('in.mbx')
> m = mb.next()
>
> The problem appears on the line "m = mb.next()", where I try to create a
> rfc822.Message object from the mailbox.
>
> Regards,
>
> Gustaf Liljegren
> --
> http://mail.python.org/mailman/listinfo/python-list
Try using a file-like object as the argument to the PortableUnixMailbox
function:
>>> from mailbox import PortableUnixMailbox
>>> mb = PortableUnixMailbox(open('nsmail/Sent'))
>>> m = mb.next()
>>> m
<rfc822.Message instance at 0x811582c>
>>>
That should work. So would a StringIO object, or any object that
implements the necessary file-like read, readline methods (and maybe a
few other methods I'm forgetting...).
joe
--
Joseph Murray
Bioinformatics Specialist, AGY Therapeutics
290 Utah Avenue, South San Francisco, CA 94080
(650) 228-1146
More information about the Python-list
mailing list