vault backup: 2025-03-12 13:14:15
Affected files: 20.01. Programming/Python/Get caller information.md
This commit is contained in:
23
20.01. Programming/Python/Get caller information.md
Normal file
23
20.01. Programming/Python/Get caller information.md
Normal 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
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
# 參考來源
|
||||||
Reference in New Issue
Block a user