How to connect functions in text file to programmed functions in source code? [duplicate]

I am searching how to connect functions written in text file to programmed functions in source code. Here is an example

In test.txt I have

create_session("azerty", 123, "test.png", "test.yaml", True)
launch_session("abc", 695, "file.txt")

In my source code I have

def create_session(self, var1: str, var2: int, var3: str, var4: str, var5: boolean)
def launch_session(self, var1: str, var2: int, var3: str)

My goal is when I read this file containing "commands" I would like to be able to connect each command to the associated function checking number of parameters and parameters.

By example the command name is "totuti" and the correct programmed function "totuti" is executed, if it is not found an error is raised. If my command in text file contains only 4 parameters and the source code programmed function needs 5 parameters, it doesn’t work. The same process is executed checking parameters type.

My question is : does any package exist to do this ? Is there any way to check parameters type ?

%d bloggers like this: