File I/O, rfc822, and stdin/stdout

Donn Cave donn at oz.net
Sun Jan 14 23:50:59 EST 2001


Quoth Sheila King <sheila at thinkspot.net>:
[... re From and Return-Path ]
| Well, apparently rfc822 requires those lines, because at least now it is
| delivering a message.

Alas, it doesn't require those lines.  You can whomp up a test message
to see what will fly, and really just about anything goes.

[... re body = fileobject.read() ]
| Secondly, why is "print body" causing this line?
| <rfc822.Message instance at 80bf6d8>
| ?

It isn't. I don't know what's going on there, but if it helps,
that's the "repr" of the Message instance.  Python naturally
endows an object with two text display functions, repr and str.
The rfc822.Message class implements its own str function (__str__()),
and lets the repr work out per default Python convention.  That
str function is what you're trying to use to display the headers,
when you say "print inheaders" -- print invokes the str function
of the objects it displays.  The repr will come out in other
circumstance, for example the str function of a list or other
such container will repr its contents.

Like I say, have no idea where that's coming from.  I would have
to believe that the program you posted really wasn't the one that
produced the output you posted.  The mail system you're working
with may be playing tricks on you.  Your post yesterday showed
a good empirical approach to the problem, but already was running
into some inexplicable contradictions, so I guess you're in for
either more basic empirical research or better documentation.

	Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list