title: Python newest file in a directory
body: <p>I am working on a script where I am trying to list the newest file ending with .xls. It should be easy, but I am receiving some errors.</p>
  
  <p>Code:</p>
  
  <pre><code>for file in os.listdir('E:\\Downloads'):
      if file.endswith(".xls"):
          print "",file
          newest = max(file , key = os.path.getctime)
          print "Recently modified Docs",newest
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Python27\sele.py", line 49, in &lt;module&gt;
      newest = max(file , key = os.path.getctime)
    File "C:\Python27\lib\genericpath.py", line 72, in getctime
      return os.stat(filename).st_ctime
  WindowsError: [Error 2] The system cannot find the file specified: 'u'
  </code></pre>