title: How to open a random file from a directory in python?
body: <p>I want to open a random file from a given directory.
  I tried this:</p>
  
  <pre><code>import os, random
  random.choice(os.listdir("C:\\"))
  </code></pre>
  
  <p>but it's not working.
  I tried this on the other hand: </p>
  
  <pre><code>import os, random
  
  random.choice([x for x in os.listdir("C:\\") if os.path.isfile(os.path.join("C:\\", x))])
  </code></pre>
  
  <p>It worked but it's only listing the files in the directory but not starting them. How do I start these files?</p>