import importlib


def get_class_from_path(class_path):
    """
    Retrieve a class from a Python path string.

    For example, get_class_from_path('users.models.User') would return the User class
    (which you can then instantiate, use for `instanceof` tests, and so on).
    """
    module_name, class_name = class_path.rsplit('.', 1)
    module = importlib.import_module(module_name)
    return getattr(module, class_name)