-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCallee.py
More file actions
26 lines (20 loc) · 806 Bytes
/
Callee.py
File metadata and controls
26 lines (20 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Callee.py
#from inspect import currentframe, stack
from inspect import stack
from os import path
def get_caller_info():
# first get the full filename (including path and file extension)
callee_frame = stack()[0]
caller_frame = stack()[1]
caller_filename_full = caller_frame.filename
print("\nstack()[0]._fields\n {}\n".format(stack()[0]._fields))
print("stack()[0]")
for a in range(len(stack()[0])):
print (" {} : {} : {}".format(a, stack()[0][a].__class__.__name__, stack()[0][a]))
print()
print("stack()[1]")
for y in range(len(stack()[1])):
print (" {} : {} : {}".format(y, stack()[1][y].__class__.__name__, stack()[1][y]))
print()
# return both filename versions as tuple
#return caller_filename_full, caller_filename_only