I’m trying to combine your two posts now, is this how you want them to work?
import rhinoscriptsyntax as rs
outerframes = inspect.getouterframes(inspect.currentframe(), 0)
callerInfo = outerframes
f_code = callerInfo.f_code
functionName = f_code.co_name
completeFilename = f_code.co_filename
# Remove the .py extension from filename
filename = os.path.basename(completeFilename)[0:-3]
f_locals = callerInfo.f_locals
args = f_locals.items()
argsCount = f_code.co_argcount
args = args[0:argsCount]
return filename, functionName, args
def TestLocals(argument_A = 0, argument_B = "True"):
argument_A = 1
argument_B = "False"
locals() # Remove this line for a different result!
return argument_A, argument_B
That does not show the correct result, as you mentioned:
('TempScript', 'TestLocals', [('argument_A', 0), ('argument_B', 'True')])
locals() gets me back to the normal stuff. This gets me back to my original question :), is it possible to remove it in your code?
If not, I would really look into the function decorator I mentioned in the other thread. It won’t print the “current” value of the arguments as they are inside the function body, but I think you could modify it to print these before and after the function runs.
If you really need debug prints of the variables inside the function, I think
logging.debug(locals()) is what you need, and the
CallerInfo function (or the decorator) can have the role of just printing the variables as they are when entering the function call. Would that work?