Access variable inside of a funciton from another function

If I understand correctly the purpose of the Python Fire library that you are trying to replicate, it does not seem to look at variables inside other functions, but instead it uses reflection to inspect the list of parameters of a method, print them to the user, and interpret command line arguments to call some registered function and pass the arguments to it.

If you want to do more (print extra info on the parameters that is not readily available by reflexivity), maybe you could establish some convention, as that extra info is stored in a const global with the name of the function plus a suffix, and check if it is defined when you register a function. If it is, you use the information provided there to complement your output. I am not sure however, how this would work with Julia allowing multiple definitions of the same function. Python allows function overload by the method signature? How PythonFire deals with that?

Someone with more experience than me could say if this a good idea.

1 Like