Using:
traceback.print_stack()
I can get:
File \"x.py\", line 20, in
y(x)
File \"x.py\", line 11, in
You can use the inspect module for this:
>>> import inspect
... def fn(x):
... try:
... print(1/0)
... except ZeroDivisionError as e:
... frames = inspect.trace()
... argvalues = inspect.getargvalues(frames[0][0])
... print("Argvalues: ", inspect.formatargvalues(*argvalues))
>>> fn(12)
Argvalues: (x=12)