Skip to content

Commit 89fe552

Browse files
committed
Emphasize that callsite_filename also works in the REPL
1 parent bcb1c0b commit 89fe552

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

unpythonic/misc.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,9 @@ def callsite_filename():
772772
"""Return the filename of the call site, as a string.
773773
774774
Useful as a building block for debug utilities and similar.
775+
776+
The filename is grabbed from the call stack using `inspect`.
777+
This works also in the REPL (where `__file__` is undefined).
775778
"""
776779
stack = inspect.stack()
777780
frame = stack[1].frame

0 commit comments

Comments
 (0)