is_dir

pyhelpers.dirs.is_dir(path_to_dir)[source]

Check whether a directory-like string is a (valid) directory name.

See also [DIRS-IVD-1] and [DIRS-IVD-2].

Parameters:

path_to_dir (str | bytes) – pathname of a directory

Returns:

whether the input is a path-like string that describes a directory name

Return type:

bool

Examples:

>>> from pyhelpers.dirs import cd, is_dir

>>> x = "tests"
>>> is_dir(x)
False

>>> x = "/tests"
>>> is_dir(x)
True

>>> x = cd("tests")
>>> is_dir(x)
True