Here is my issue. I’m writing a logging function, which needs to know ‘Who called me’. I use inspect to to that. I want to know the filename, the function name and all the arguments. Here is the code:
stack = inspect.stack() functionName = stack callerInfo = stack f_code = callerInfo.f_code completeFilename = f_code.co_filename # Remove the .py extension from filename filename = os.path.basename(completeFilename)[0:-3] f_back = callerInfo.f_back f_locals = f_back.f_locals args = f_locals.items() argsCount = f_code.co_argcount args = args[0:argsCount] return filename, functionName, args
This works well in debug mode, after having used the play button and having set at least 1 break point at some place. After that, I always get the correct answer, debugging or not. However, if I use that without having done any debugging before (play button without any break point), the ‘args’ output fails. It looks like that
print args → [(‘name’, ‘main’), (‘exit’, <System.Action object at 0x000000000000009E [System.Action]>), (‘file’, ‘C:\Users\User\Documents\Job\Bitbucket\python\Buttons\Button_Load.py’)]
In debug mode with a break point (and thereafter), what I get is like:
print args → [(‘param1’, value1), (‘param2’, ‘string2’), (‘param3’, False)]
Any idea what is going on? Is there a clean way to do that? Or at least tell Rhino “Yes I have debugged the stuff using a break point” without doing so?