Module rfc822 - uses file-objects - why?
Aahz Maruch
aahz at panix.com
Thu Feb 22 12:50:01 EST 2001
In article <Tccl6.19348$AH6.2625576 at newsc.telia.net>,
Fredrik Lundh <fredrik at effbot.org> wrote:
>Thomas Volkmar Worm wrote:
>>
>> I started to write a little programm which reads mails from a POP3
>> account. To handle the message I thought, I use the rfc822 module or one
>> of its subclasses (mimetools). But the methods I want to use always
>> expect file-objects as parameters. Do I need to store every list/string
>> onto disk when I want to use these classes or methods on them?
>
>import StringIO
>file = StringIO.StringIO(data)
For performance:
try:
from StringIO import StringIO
except ImportError:
from cStringIO import StringIO
(I learned that idiom back when cStringIO wasn't automatically compiled;
I'm not sure it's necessary anymore.)
--
--- Aahz (Copyright 2001 by aahz at pobox.com)
Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6
"I used to have a .sig but I found it impossible to please everyone..." --SFJ
More information about the Python-list
mailing list