<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Standard Out on shocksolution.com</title><link>https://shocksolution.com/tags/standard-out/</link><description>Recent content in Standard Out on shocksolution.com</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Sat, 16 Aug 2008 20:47:05 +0000</lastBuildDate><atom:link href="https://shocksolution.com/tags/standard-out/index.xml" rel="self" type="application/rss+xml"/><item><title>Redirecting text output from Python functions</title><link>https://shocksolution.com/posts/redirecting-text-output-from-python-functions/</link><pubDate>Sat, 16 Aug 2008 20:47:05 +0000</pubDate><guid>https://shocksolution.com/posts/redirecting-text-output-from-python-functions/</guid><description>&lt;p&gt;Two posts ago, I described how I wrote a function in Python that reads in a binary file from Labview. In my last post, I described using wxPython to write a GUI to process the data from those binary files. Naturally, I called the binary-file-reader function from the GUI. The problem is that the file reader prints a lot of information to the terminal, using Python &lt;strong&gt;print&lt;/strong&gt;statements. None of this goes to the GUI, requiring the user to run the GUI from a terminal and keep an eye on the text output, which is inconvenient. However, I don&amp;rsquo;t want to modify the file reader to include GUI-specific code, because that would be less modular and less re-usable. Instead, I learned that Python has a very easy facility to redirect&lt;strong&gt;stdout&lt;/strong&gt;, the default destination of the &lt;strong&gt;print&lt;/strong&gt; statement. I modified the file reader as follows:&lt;/p&gt;</description></item></channel></rss>