title: Python: how to get the first file in directory?
body: <p>So I want to grab the first file under a directory in Python. I know I can do like this:</p>
  
  <pre><code>first_file = [join(path, f) for f in os.listdir(path) if isfile(join(path, f))][0]
  </code></pre>
  
  <p>But it's slow. Is there any better solution? Thanks!</p>