Using poplib to parse headers

alex23 wuwei23 at gmail.com
Mon May 26 19:24:20 EDT 2008


On May 27, 8:39 am, Jean-Claude Neveu <jcn-france1... at pobox.com>
wrote:
> I tried to do this by using in the i loop the line:
>
>         message = email.message_from_file(j)
>
> but I get the error: "AttributeError: 'str' object has no attribute 'readline'"

Heya,

The email module has a second function - 'message_from_string' - which
might be more useful here. Currently, you're passing to
'message_from_file' a string that it tries to treat as a file, hence
it complaining about the string object not having part of the file
object interface.

(I've never used email or poplib, so this is just a guess...)

- alex23



More information about the Python-list mailing list