os.chroot(path)

Change the root directory of the current process to path.

Availability: Unix.

Changed in version 3.6: Accepts a path-like object.

Related Reading

os — Miscellaneous operating system interfaces