<div><h3id="direntry">DirEntry</h3><p><strong>Using scandir() instead of listdir() can significantly increase the performance of code that also needs file type information.</strong></p><pre><codeclass="python language-python hljs"><iter> = scandir(path=<spanclass="hljs-string">'.'</span>) <spanclass="hljs-comment"># Returns DirEntry objects located at path.</span>
<div><h3id="direntry">DirEntry</h3><p><strong>Using scandir() instead of listdir() can significantly increase the performance of code that also needs file type information.</strong></p><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">from</span> os<spanclass="hljs-keyword">import</span> scandir
</code></pre></div>
<pre><codeclass="python language-python hljs"><str> = <DirEntry>.path <spanclass="hljs-comment"># Returns path as a string.</span>
<pre><codeclass="python language-python hljs"><iter> = scandir(path=<spanclass="hljs-string">'.'</span>) <spanclass="hljs-comment"># Returns DirEntry objects located at path.</span>
<str> = <DirEntry>.path <spanclass="hljs-comment"># Returns path as a string.</span>
<str> = <DirEntry>.name <spanclass="hljs-comment"># Returns final component as a string.</span>
<file> = open(<DirEntry>) <spanclass="hljs-comment"># Opens the file and returns a file object.</span>