* **`'encoding=None'` means default encoding is used, which is platform dependent. Best practice is to use `"encoding='utf-8'"` whenever possible.**
* **`'encoding=None'` means default encoding is used, which is platform dependent. Best practice is to use `'encoding="utf-8"'` whenever possible.**
* **`'endline=None'` means all different end of line combinations are converted to '\n' on read, while on write all '\n' characters are converted to system's default line separator.**
* **`'endline=None'` means all different end of line combinations are converted to '\n' on read, while on write all '\n' characters are converted to system's default line separator.**
### Modes
### Modes
@ -1318,21 +1318,26 @@ Path
----
----
```python
```python
from os import path, listdir
from os import path, listdir
from glob import glob
```
```python
<bool> = path.exists('<path>')
<bool> = path.exists('<path>')
<bool> = path.isfile('<path>')
<bool> = path.isfile('<path>')
<bool> = path.isdir('<path>')
<bool> = path.isdir('<path>')
<list> = listdir('<path>')
```
```
```python
```python
>>> from glob import glob
>>> glob('../*.gif')
['1.gif', 'card.gif']
<list> = listdir('<path>') # List of filenames located at 'path'.
<list> = glob('<pattern>') # Filenames matching the wildcard pattern.
```
```
### Pathlib
### Pathlib
```python
```python
from pathlib import Path
from pathlib import Path
```
```python
cwd = Path()
cwd = Path()
<Path> = Path('<path>' [, '<path>', <Path>, ...])
<Path> = Path('<path>' [, '<path>', <Path>, ...])
<Path> = <Path> / '<dir>' / '<file>'
<Path> = <Path> / '<dir>' / '<file>'
@ -1342,11 +1347,11 @@ cwd = Path()
<bool> = <Path>.exists()
<bool> = <Path>.exists()
<bool> = <Path>.is_file()
<bool> = <Path>.is_file()
<bool> = <Path>.is_dir()
<bool> = <Path>.is_dir()
<iter> = <Path>.iterdir()
```
```
```python
```python
<iter> = <Path>.glob('<pattern>')
<iter> = <Path>.iterdir() # Iterator with filenames located at path.
<iter> = <Path>.glob('<pattern>') # Filenames matching the wildcard pattern.
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'encoding=None'</span></code> means default encoding is used, which is platform dependent. Best practice is to use <codeclass="python hljs"><spanclass="hljs-string">"encoding='utf-8'"</span></code> whenever possible.</strong></li>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'encoding=None'</span></code> means default encoding is used, which is platform dependent. Best practice is to use <codeclass="python hljs"><spanclass="hljs-string">'encoding="utf-8"'</span></code> whenever possible.</strong></li>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'endline=None'</span></code> means all different end of line combinations are converted to '\n' on read, while on write all '\n' characters are converted to system's default line separator.</strong></li>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'endline=None'</span></code> means all different end of line combinations are converted to '\n' on read, while on write all '\n' characters are converted to system's default line separator.</strong></li>
<pre><codeclass="python language-python hljs"><list> = listdir(<spanclass="hljs-string">'<path>'</span>) <spanclass="hljs-comment"># List of filenames located at 'path'. </span>
<list> = glob(<spanclass="hljs-string">'<pattern>'</span>) <spanclass="hljs-comment"># Filenames matching the wildcard pattern.</span>
<pre><codeclass="python language-python hljs"><iter> = <Path>.iterdir() <spanclass="hljs-comment"># Iterator with filenames located at path.</span>
<iter> = <Path>.glob(<spanclass="hljs-string">'<pattern>'</span>) <spanclass="hljs-comment"># Filenames matching the wildcard pattern.</span>
</code></pre>
</code></pre>
<pre><codeclass="python language-python hljs"><str> = str(<Path>) <spanclass="hljs-comment"># Returns path as a string.</span>
<pre><codeclass="python language-python hljs"><str> = str(<Path>) <spanclass="hljs-comment"># Returns path as a string.</span>
<tup.> = <Path>.parts <spanclass="hljs-comment"># Returns all components as strings.</span>
<tup.> = <Path>.parts <spanclass="hljs-comment"># Returns all components as strings.</span>