Sobes.tech
Junior — Senior

Why does the '/' operator work with pathlib, even though it is a division operator

livecode

Task condition

Explain how the expression with "/" works, despite the fact that in Python this symbol usually denotes division, and what happens during the process.

app_model = ...

# app_model.path: pathlib.Path
# app_model.path = pathlib.Path("/home/user/app/")
# ALLOWED_PATH = "dir1/dir2"

if app_model.path / ALLOWED_PATH not in path.parents:
    raise django.core.exceptions.PermissionDenied()