title: Python FTP Most Recent File
body: <p>How do I determine the most recently modified file from an ftp directory listing? I used the max function on the unix timestamp locally, but the ftp listing is harder to parse. The contents of each line is only separated by a space. </p>
  
  <pre><code>from ftplib import FTP
  ftp = FTP('ftp.cwi.nl')
  ftp.login()
  data = []
  ftp.dir(data.append)
  ftp.quit()
  for line in data:
      print line
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>drwxrwsr-x   5 ftp-usr  pdmaint     1536 Mar 20 09:48 .
  dr-xr-srwt 105 ftp-usr  pdmaint     1536 Mar 21 14:32 ..
  -rw-r--r--   1 ftp-usr  pdmaint     5305 Mar 20 09:48 INDEX
  </code></pre>