Question: How do I delete a file or folder?

Answer: 
My personal preference is to work with pathlib objects - it offers a more pythonic and less error-prone way to interact with the filesystem, especially if You develop cross-platform code.

In that case, You might use pathlib3x - it offers a backport of the latest (at the date of writing this answer Python 3.10.a0) Python pathlib for Python 3.6 or newer, and a few additional functions like "copy", "copy2", "copytree", "rmtree" etc ...

It also wraps `shutil.rmtree`:

```
$> python -m pip install pathlib3x
$> python
>>> import pathlib3x as pathlib

# delete a directory tree
>>> my_dir_to_delete=pathlib.Path('c:/temp/some_dir')
>>> my_dir_to_delete.rmtree(ignore_errors=True)

# delete a file
>>> my_file_to_delete=pathlib.Path('c:/temp/some_file.txt')
>>> my_file_to_delete.unlink(missing_ok=True)

```

you can find it on [github](https://github.com/bitranox/pathlib3x) or [PyPi](https://pypi.org/project/pathlib3x)

---

Disclaimer: I'm the author of the pathlib3x library.
I recommend using `subprocess` if writing a beautiful and readable code is your cup of tea:

```
import subprocess
subprocess.Popen("rm -r my_dir", shell=True)

```

And if you are not a software engineer, then maybe consider using Jupyter; you can simply type bash commands:

```
!rm -r my_dir

```

Traditionally, you use `shutil`:

```
import shutil
shutil.rmtree(my_dir) 

```