smtplib, capturing output from set_debuglevel ??

Tim Williams listserver at tdw.net
Fri Oct 8 10:04:21 EDT 2004


----- Original Message ----- 
From: "Steve Holden" <steve at holdenweb.com>


> AT this point I might be tempted to modify the smtplib code so it
> doesn't use sys.stdout for its debug output, but some other object that
> can be passed to SMTP.__init__().
>
> Since sys.stdout is going to be common to all modules, I think you have
> highlighted a weakness in the smtplib debugging paradigm. But if some
> smart type can come up with a better solution I'd love to see it.

Yeah,  I did wonder about changing the code  (though it's not my first
choice. I've done it before and caught a crab later),   or could I do it
with Subclassing?

 I'm still close to Newbie status, so I can't immediately imagine what  I
could change the smptblib code to write to,    or  how to subclass to get
the behaviour I might need.


"Peter L Hansen" <peter at engcorp.com> wrote in message
news:zbidndU9vdoBDPvcRVn-rA at powergate.ca...
> Tim Williams wrote:
> > 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.

Thanks Peter,   nothing else modifies sys.stdout within the prog,  so I was
able to use this.  :-)




More information about the Python-list mailing list