diff --git a/20.01. Programming/Python/Get caller information.md b/20.01. Programming/Python/Get caller information.md new file mode 100644 index 0000000..0f66a86 --- /dev/null +++ b/20.01. Programming/Python/Get caller information.md @@ -0,0 +1,23 @@ +--- +tags: +aliases: +date: 2025-03-12 +time: 13:10:38 +description: +--- + +```python +def getCallerInfo(msg): + callerFrame = inspect.currentframe().f_back + func_name = callerFrame.f_code.co_name + + class_name = "" + if 'self' in caller_frame.f_locals: + class_name = caller_frame.f_locals['self'].__class__.__name__' + + filename = os.path.basename(callerFrame.f_code.co_filename) + lineno = callerFrame.f_lineno +``` + + +# 參考來源 \ No newline at end of file