title: AttributeError: 'str' object has no attribute 'fileno'
body: <p>Code:</p>
  
  <pre><code>import subprocess
  
  def printit():
      for i in range(6):
          for j in range(6):
              query = "select rxpkts, txpkts from ./log.csv where datapath = "+str(i)+" and port = "+str(j)
              fileName = str(i)+"_"+str(j)+".csv"
              with open(fileName, "w+"):
                  p = subprocess.Popen(["python", "q", "-H", "-d", ",", query], stdout=fileName)
  
  printit()
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>$ python processLog.py 
  Traceback (most recent call last):
    File "processLog.py", line 11, in &lt;module&gt;
      printit()
    File "processLog.py", line 9, in printit
      p = subprocess.Popen(["python", "q", "-H", "-d", ",", query], stdout=fileName)
    File "/usr/lib/python2.7/subprocess.py", line 702, in __init__
      errread, errwrite), to_close = self._get_handles(stdin, stdout, stderr)
    File "/usr/lib/python2.7/subprocess.py", line 1128, in _get_handles
      c2pwrite = stdout.fileno()
  AttributeError: 'str' object has no attribute 'fileno'
  </code></pre>
  
  <p>What could be the issue? I am using <a href="https://github.com/harelba/q" rel="noreferrer"><code>q</code></a></p>