<str> = path.realpath(<path>) # Resolves symlinks and calls path.abspath().
```
```python
@ -1642,8 +1642,8 @@ from glob import glob
```
```python
<list> = listdir(path='.') # Returns filenames located at the path.
<list> = glob('<pattern>') # Returns paths matching the wildcard pattern.
<list> = os.listdir(path='.') # Returns filenames located at the path.
<list> = glob.glob('<pattern>') # Returns paths matching the wildcard pattern.
```
```python
@ -1661,20 +1661,17 @@ from glob import glob
**Unlike listdir(), scandir() returns DirEntry objects that cache isfile, isdir and on Windows also stat information, thus significantly increasing the performance of code that requires it.**
```python
<iter> = scandir(path='.') # Returns DirEntry objects located at the path.
<iter> = os.scandir(path='.') # Returns DirEntry objects located at the path.
<str> = <DirEntry>.path # Returns the whole path as a string.
<str> = <DirEntry>.name # Returns final component as a string.
<file> = open(<DirEntry>) # Opens the file and returns a file object.
<str> = path.realpath(<path>) <spanclass="hljs-comment"># Resolves symlinks and calls path.abspath().</span>
</code></pre>
<pre><codeclass="python language-python hljs"><str> = path.basename(<path>) <spanclass="hljs-comment"># Returns final component of the path.</span>
<str> = path.dirname(<path>) <spanclass="hljs-comment"># Returns path without the final component.</span>
<tup.> = path.splitext(<path>) <spanclass="hljs-comment"># Splits on last period of the final component.</span>
</code></pre>
<pre><codeclass="python language-python hljs"><list> = listdir(path=<spanclass="hljs-string">'.'</span>)<spanclass="hljs-comment"># Returns filenames located at the path.</span>
<list> = glob(<spanclass="hljs-string">'<pattern>'</span>)<spanclass="hljs-comment"># Returns paths matching the wildcard pattern.</span>
<pre><codeclass="python language-python hljs"><list> = os.listdir(path=<spanclass="hljs-string">'.'</span>) <spanclass="hljs-comment"># Returns filenames located at the path.</span>
<list> = glob.glob(<spanclass="hljs-string">'<pattern>'</span>) <spanclass="hljs-comment"># Returns paths matching the wildcard pattern.</span>
<real> = <stat>.st_mtime/st_size/… <spanclass="hljs-comment"># Modification time, size in bytes, ...</span>
</code></pre>
<div><h3id="direntry">DirEntry</h3><p><strong>Unlike listdir(), scandir() returns DirEntry objects that cache isfile, isdir and on Windows also stat information, thus significantly increasing the performance of code that requires it.</strong></p><pre><codeclass="python language-python hljs"><iter> = scandir(path=<spanclass="hljs-string">'.'</span>)<spanclass="hljs-comment"># Returns DirEntry objects located at the path.</span>
<div><h3id="direntry">DirEntry</h3><p><strong>Unlike listdir(), scandir() returns DirEntry objects that cache isfile, isdir and on Windows also stat information, thus significantly increasing the performance of code that requires it.</strong></p><pre><codeclass="python language-python hljs"><iter> = os.scandir(path=<spanclass="hljs-string">'.'</span>) <spanclass="hljs-comment"># Returns DirEntry objects located at the path.</span>
<str> = <DirEntry>.path <spanclass="hljs-comment"># Returns the whole 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>
os.makedirs(<path>, mode=<spanclass="hljs-number">0o777</span>) <spanclass="hljs-comment"># Creates all path's dirs. Also `exist_ok=False`.</span>
</code></pre>
<pre><codeclass="python language-python hljs">shutil.copy(from, to) <spanclass="hljs-comment"># Copies the file. 'to' can exist or be a dir.</span>
shutil.copy2(from, to) <spanclass="hljs-comment"># Also copies creation and modification time.</span>
shutil.copytree(from, to) <spanclass="hljs-comment"># Copies the directory. 'to' must not exist.</span>
</code></pre>
<pre><codeclass="python language-python hljs">os.rename(from, to) <spanclass="hljs-comment"># Renames/moves the file or directory.</span>
os.replace(from, to) <spanclass="hljs-comment"># Same, but overwrites 'to' if it exists.</span>
os.replace(from, to) <spanclass="hljs-comment"># Same, but overwrites file 'to' even on Windows.</span>
shutil.move(from, to) <spanclass="hljs-comment"># Rename() that moves into 'to' if it's a dir.</span>
</code></pre>
<pre><codeclass="python language-python hljs">os.remove(<path>) <spanclass="hljs-comment"># Deletes the file.</span>
os.rmdir(<path>) <spanclass="hljs-comment"># Deletes the empty directory.</span>