[OnePoint Python] pathlib, shutil, tempfile
A simple example of Python modules that are often used but seem difficult.
Some python modules are useful yet seem difficult.
pathlib
— Object-oriented filesystem pathstempfile
— Generate temporary files and directoriesshutil
— High-level file operations
The following example makes a new temporary directory logdir
and delete all files and sub-directories under logdir
.
import pathlib
import shutil
import tempfilelogdir = pathlib.Path(tempfile.mkdtemp())/"tensorboard_logs"
shutil.rmtree(logdir, ignore_errors=True)