email module, redirecting to stdout

Laszlo Zsolt Nagy gandalf at designaproduct.biz
Tue Oct 4 10:05:30 EDT 2005


  Hello,

I have this code:

        s = smtplib.SMTP()
        s.set_debuglevel(1)
        s.connect(host=smtp_host)
        s.set_debuglevel(0)
        log("Connected, sending e-mail")
        sys.stdout.flush()       
        s.sendmail(
            consts.EMAIL_FROMADDRESS,
            [to],
            msg.as_string()
        )
        log("E-mail sent OK")
        s.quit()

The problem is that whenever I set the debuglevel to 1, messages will go 
to stderr. I would like them to go to stdout. Using

sys.stderr = sys.stdout

has no effect. Redirecting stderr to stdout from the shell is not an 
option for me, because I need to use stderr for other messages.

Thanks,

   Les




More information about the Python-list mailing list