from pathlib import Path
from os import path
from inspect import getfile
from typing import Callable, Type


def get_location(
    file: Path|str = None,
    func: Callable|Type = None
) -> Path|str|None:
    """
    Get location of given file/function.

    :param file: file object (__file__)
    :param func: function object (lambda _: 0)
    :return: 'location/if-can-be-found'
    """

    # init -----
    if file is not None:
        return Path(file).parent

    elif func is not None:
        return path.dirname(path.abspath(getfile(func)))
        # return Path(getfile(func)).parent.absolute()

    else:
        return None

    pass
