<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div><br></div><blockquote type="cite"><div class="gmail_quote">On 7 November 2011 14:51, Emmanuel Bacry <span dir="ltr"><<a href="mailto:emmanuel.bacry@polytechnique.fr">emmanuel.bacry@polytechnique.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto; ">

<div>I have some problem using this last advice for redirection. Let me explain.</div><div><div><div>If I override sys.stdout before creating the InteractiveShell, then it fails :</div><div><br></div></div></div></blockquote>

<div><br>Looking at the code for <a href="http://IPython.utils.io/">IPython.utils.io</a>, it seems your stdout object needs to have both .write() and .flush() methods. With this done, the default displayhook should just work.<br>

<br>Thomas<br></div></div>
</blockquote></div><br><div>Yes, I'm sorry I could have find it myself.</div><div><br></div><div>However I have another problem :</div><div><br></div><div>Under wxPython I create an interactiveShell. I have a single button so that when I click on it a thread is ran in which a command is sent to the interactive shell:</div><div>(I did not redirect any of stdout or sterr)</div><div><br></div><div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><span class="Apple-tab-span" style="white-space:pre">   </span>interactiveshell.run_cell(command)</div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><br></div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">If the command is valid, everything goes well. If not (for instance command = "ytytyutuy") then the thread never terminates and nothing is printed on stderr</div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><br></div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">Emmanuel</div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><br></div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><br></div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><!--EndFragment--></div></div></body></html>