Two email module questions
Paul Mackinney
paul at mackinney.net
Thu Jan 9 04:26:42 EST 2003
1. There are two obvious ways to use email.message_from_file. Am I
correct in assuming that method a. is prefered, because method b. leaves
an open file with no convenient way to close it?
a. fn = file('foo','r')
msg = email.message_from_file(fn)
fn.close()
b. msg = email.message_from_file(file('foo','r'))
2. After importing a message, I get a bogus extra line at the top when I
print it:
---begin foo---
From: Paul Mackinney <paul at mackinney.net>
To: debian <debian-user at lists.debian.org>
Cc:
Bcc:
Subject: The fascinating story of my life
I eat a lot of spam.
---end foo--
>>> msg = message_from_file('foo')
>>> print msg
From nobody Thu Jan 9 01:16:54 2003
From: Paul Mackinney <paul at mackinney.net>
To: debian <debian-user at lists.debian.org>
Cc:
Bcc:
Subject: The fascinating story of my life
I eat a lot of spam.
>>>
What's going on here? The 'From nobody...' line doesn't show in
msg.keys(), I couldn't find this behavior in the docs.
TIA, Paul
--
Paul Mackinney
paul at mackinney.net
More information about the Python-list
mailing list