is_dir

pyhelpers.dirs.is_dir(path_to_dir)[source]

Check whether a string represents a valid directory path.

This function verifies whether the input string is a valid directory path. See also [DIRS-IVD-1] and [DIRS-IVD-2].

Parameters:

path_to_dir (str | bytes) – Pathname of a directory.

Returns:

True if the input string is a valid directory path, False otherwise.

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