diff --git a/_posts/2020-07-14-python-3-cheatsheet.md b/_posts/2020-07-14-python-3-cheatsheet.md index 7600825..9a643b6 100644 --- a/_posts/2020-07-14-python-3-cheatsheet.md +++ b/_posts/2020-07-14-python-3-cheatsheet.md @@ -1,7 +1,7 @@ --- title: Python 3 cheatsheet tags: [python3, python, cheatsheet] -updated: 2021-04-18 23:10 +updated: 2021-04-19 00:13 description: A series of instructions in Python I use frequently on several projects --- @@ -46,9 +46,10 @@ This is a list of instructions I use frequently in: | get full path | `str(pathlib.Path(shlex.quote(directory: str), shlex.quote(file: str)))` | `import pathlib, shlex` | | remove file extension | `pathlib.Path(shlex.quote(path: str)).stem` | `import pathlib, shlex` | | get file extension | `pathlib.Path(shlex.quote(path: str)).suffix` | `import pathlib, shlex` | +| get the path of a configuration file | `configuration_file = shlex.quote(sys.argv[1])` | `import shlex, sys` | ## PyYAML | Description | Code | Imports | |-------------|-------------------------------------------------|---------| -| load a YAML file | `yaml.load(open('a.yaml', 'r'), Loader=yaml.SafeLoader)` | `import yaml` | +| load a YAML file | `config = yaml.load(open(file: str, 'r'), Loader=yaml.SafeLoader)` | `import yaml` |