smtplib, capturing output from set_debuglevel ??

Peter L Hansen peter at
Fri Oct 8 15:09:48 CEST 2004

Tim Williams wrote:
> I have implemented your suggestion ,   but what is the best way to get the
> data out of the file-like object,   the only option that seems to work for
> me is
> f.getvalue()
> which returns a string,  but getvalue() doesn't "feel" right somehow.   Am I
> missing something ?

I've never felt the name "spoke to me" very well either :-), but
it is the correct way to do it.

Note also, regarding Steve's suggestion, that for simplicity
in a small program you don't need to save sys.stdout if you
are doing that just to restore it later, because sys.__stdout__
is always the original value and a quick sys.stdout == sys.__stdout__
will do the trick.


More information about the Python-list mailing list