<jupyter_start><jupyter_text>Function Introspection<jupyter_code>#dummy code
i = 100


#  TODO:  Fix this function
# currently does nothing, but should do ....
def my_func(a: "mandatory positional",
            b: "optional positional"=1,
            c=2,
            *args: "add extra positional here",
            kw1,
            kw2=100,
            kw3=200,
            **kwargs: "provide extra kw-only here") -> "does nothing":
    """This function does nothing but does have various parameters and annotations.
    """
    i = 10
    j = 20
    a = i + j
    return a
my_func.__doc__
my_func.__annotations__
my_func.short_description = "this is a function that does nothing much"
my_func.short_description
dir(my_func)
my_func.__name__
my_func.__name__
id(my_func)
def func_call(f):
    print(id(f))
    print(f.__name__)
func_call(my_func)
my_func.__defaults__
my_func.__kwdefaults__
my_func.__code__
dir(my_func.__code__)
my_func.__code__.co_name
my_func.__code__.co_varnames
my_func.__code__.co_argcount
import inspect
from inspect import isfunction, ismethod, isroutine
a = 10
isfunction((a))
isfunction((my_func))
ismethod(my_func)
class MyClass:
    def f(self):
        pass
isfunction((MyClass.f))
my_obj = MyClass()
my_obj = MyClass()
isfunction(my_obj.f)
ismethod(my_obj.f)
isroutine((MyClass.f))
print(inspect.getsource(my_func))
inspect.getmodule(my_func)
inspect.getmodule(print)
import math
inspect.getmodule(math.sin)
inspect.getcomments((my_func))
my_func.__doc__
inspect.signature(my_func)
dir(inspect.signature(my_func))
my_func.__annotations__
inspect.signature(my_func).return_annotation
sig = inspect.signature(my_func)
sig
sig.parameters
for k, v in sig.parameters.items():
    print(k, type(v))
for k, v in sig.parameters.items():
    print(dir(v))
for param in sig.parameters.values():
    print('Name:', param.name)
    print('Default:', param.default)
    print('Annotation:', param.annotation)
    print('Kind:', param.kind)
    print('-------------------------------------------')
help(divmod)
divmod(4, 3)
divmod(x=3, y=3)
for param in inspect.signature(divmod).parameters.values():
    print(param.kind)<jupyter_output>POSITIONAL_ONLY
POSITIONAL_ONLY
{'fraction_non_alphanumeric': 0.13717421124828533, 'fraction_numerical': 0.010973936899862825, 'mean_word_length': 3.9390519187358914, 'pattern_counts': {'":': 1, '<': 4, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '498389', 'license': 'Unlicense', 'n_tokens_mistral': 764, 'n_tokens_neox': 742, 'n_words': 165, 'path': 'my_classes/FirstClassFunctions/finction-introspection.ipynb', 'repo_name': 'minefarmer/deep-Dive-1', 'size': '2187'}