def ddebug(msg, err=None):  
import os<EOL>if err:<EOL><INDENT>err = '<STR_LIT>'.join(traceback.format_exception(*err))<EOL><DEDENT>else:<EOL><INDENT>err = '<STR_LIT>'<EOL><DEDENT>sys.__stdout__.write("<STR_LIT>".format(os.getpid(), msg, err)+'<STR_LIT:\n>')<EOL>sys.__stdout__.flush()<EOL>
err can be an instance of sys.exc_info() -- which is the latest traceback
info