What is the intended way to change directory using the Python pathlib
(Documentation) functionality?
Lets assume I create a Path
object as foll
If you don't mind using a third-party library:
$ pip install path
then:
from path import Path
with Path("somewhere"):
# current working directory is now `somewhere`
...
# current working directory is restored to its original value.
or if you want to do it without the context manager:
Path("somewhere").cd()
# current working directory is now changed to `somewhere`