Is there any easy way to evaluate at runtime if a function has been specified or not? for example, i have a function/method declared:
def func_to_be_implemented():
...
I would like to have function to check whether it has been specified or not like:
def function_is_defined(func: Callable[..., Any]) -> bool:
...
Thanks in advance.
Based upon suggestions and for the purposes declared (interfaz/library), i ended up using the inspect module:
from inspect import getsource
def function_is_defined(func) -> bool:
return getsource(func).split()[-1] not in ["...", "pass"]
Notes about usage: The rskattr decorator adds, cache, validation and getters/setter funcionality. if the decorated function is defined, it will assing and cache the result of it, as an attribute. This property/attribute can also be complemented with a complex setter (the underscored function below the property) whenever it runs, it overwrites the property value and gets cached for the next retrieval.