vault backup: 2025-03-12 13:14:15

Affected files:
20.01. Programming/Python/Get caller information.md
This commit is contained in:
2025-03-12 13:14:15 +08:00
parent 06f69be4e0
commit 3610f54531

View File

@@ -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
```
# 參考來源