Python writing to terminal for no apparent reason?
<p>I have a fairly straightforward python (3.5.2) script, which reads from a file, and if the line meets certain criteria, then it copies the line into another one. The original file looks like this (this is one line, many more follow, in the same format but different numbers):</p>

<blockquote>
  <p>2.9133 1 1 157.6578 170.4160 0.7081 3044.911 351.998 152.778 -1451.315 162.109</p>
</blockquote>

<p>And my script goes like:</p>

<pre><code> inp = open("original.dat", "r")

 out = open("new.log", "w")

 for line in inp:

     if float(line.split()[5]) &lt; 5.0:

        out.write(line)
</code></pre>

<p>The program finishes the task well, I get the desired output. However, while running from the python terminal window, it spams my terminal with integers around 80 (so like 70-90) seemingly in a random fashion.</p>

<p>I have no idea what might cause this undesired output, but it messes my workspace up hard. I hope some of you may have an idea to fix it.</p>

<p>This is a normal behavior when you do <code>.write</code> on a file like that. It's the number of bytes written to the file.</p>

<pre><code>&gt;&gt;&gt; a = open("new.txt", 'w')
&gt;&gt;&gt; a.write("hello")
5
</code></pre>

<p>There's probably a more elegant solution, but you could suppress this by setting a variable to the output of <code>out.write</code></p>

<pre><code>foo = out.write(line)
</code></pre>

python