File I/O, rfc822, and stdin/stdout

Donn Cave donn at u.washington.edu
Tue Jan 16 14:51:58 EST 2001


Quoth ssthapa at harper.uchicago.edu ():
| Sheila King <sheila at thinkspot.net> wrote:
|>
|> <rfc822.Message instance at 80bf6d8>
|
|     Your python script doesn't seem to understand how to print 
| objects from the rfc822 module.  In particular I believe you need to
| read the fp instance variable and print the data it returns.  E.g.
|
| for line in foo.fp.readlines():
|     print line
|
| or something like that.

That would work, but then her example would work too.  rf822.Message
has a __str__() function that returns the header lines.

Which is OK, as long as the resulting line separators work out OK.
Some data will end with '\r\n' and will need to be converted to
'\n', or vice versa.  Actual RFC822 protocol probably says nothing
about that, as far as I know, but the SMTP, POP and IMAP protocols
that carry it are CRLF, also some relatively obscure folder formats;
meanwhile, conventional UNIX mail is LF.

	Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list