title: How to open every file in a folder
body: <p>I have a python script parse.py, which in the script open a file, say file1, and then do something maybe print out the total number of characters. </p>
  
  <pre><code>filename = 'file1'
  f = open(filename, 'r')
  content = f.read()
  print filename, len(content)
  </code></pre>
  
  <p>Right now, I am using stdout to direct the result to my output file - output</p>
  
  <pre><code>python parse.py &gt;&gt; output
  </code></pre>
  
  <p>However, I don't want to do this file by file manually, is there a way to take care of every single file automatically? Like</p>
  
  <pre><code>ls | awk '{print}' | python parse.py &gt;&gt; output 
  </code></pre>
  
  <p>Then the problem is how could I read the file name from standardin? 
  or there are already some built-in functions to do the ls and those kind of work easily?</p>
  
  <p>Thanks!</p>