title: glob.iglob Remove path from filename
body: <p>I am trying to get the most recent file added to a directory using python 2.7 <code>os</code> and <code>glob</code> modules. </p>
  
  <pre><code>import os
  import glob
  
  path = "files/"
  newestFile = max(glob.iglob(path + '*.txt'), key=os.path.getctime)
  
  print newestFile
  </code></pre>
  
  <p>When I print the <code>newestFile</code> variable I get the path included i.e. </p>
  
  <blockquote>
    <p>files\file.txt</p>
  </blockquote>
  
  <p>I just want the <code>filename</code> but my <code>.txt</code> file and <code>.py</code> script are not in the same directory. The text file is one directory down under the files directory. How do I refer to the directory and get the newest <code>.txt</code> file added to that directory. </p>