Convert pathlib.Path objects to str; return other objects as-is.

def path_to_str(path):
    """ Convert pathlib.Path objects to str; return other objects as-is. """
    try:
        from pathlib import Path as _Path
    except ImportError:  # Python < 3.4
        class _Path:
            pass
    if isinstance(path, _Path):
        return str(path)
    return path