title: Python subprocess list files without "\n"
body: <p>I'm using <code>subprocess</code> on python to list all the files/folders in one folder:</p>
  
  <pre><code>def subprocess_list(command):
    p = subprocess.Popen(command,stdout=subprocess.PIPE, shell=True)
    proc_stdout = p.communicate()[0].strip()
    lista.append(proc_stdout.decode('utf-8'))
    retcode = p.wait()
  subprocess_list('ls | grep aa')
  </code></pre>
  
  <p>When I print "lista" I get all the paths in a single-element list:</p>
  
  <pre><code>lista=[aaa\naab\naac\n]
  </code></pre>
  
  <p>So in order to separate them and get each file I first export them to a .txt, call it back and delete <code>\n</code></p>
  
  <pre><code>with open('%s/files.txt'%Path_Desktop,'w') as file:
      for item in lista:
          file.write(item)
  
  with open('%s/files.txt'%Path_Desktop) as file:
      content = file.readlines()
  content = [x.strip() for x in content]
  </code></pre>
  
  <p>Print "content":</p>
  
  <pre><code>content=['aaa','aab','aac']
  </code></pre>
  
  <p>Is there a way to do it directly without the export part? Thanks in advance!</p>