Search notes:

Python: sys._current_frames

import sys

def print_frame(frames):
    frame_addr, frame = next(iter(frames.items()))

    print(f'Frame')
    print(f'  Address      : {frame_addr}')
    print(f'  Line No      : {getattr(frame, "f_lineno"       )}')
    print(f'  Back         : {getattr(frame, "f_back"         )}')
    print(f'  Locals       : {getattr(frame, "f_locals"       )}')
    print(f'  Trace        : {getattr(frame, "f_trace"        )}')
    print(f'  Trace        : {getattr(frame, "f_trace"        )}')
    print(f'  Last i       : {getattr(frame, "f_lasti"        )}')
    print('')


def h(i):

    print_frame(sys._current_frames())

def f(a):
    x = 42

    def g(b):
        x = 'hello world'

        h(b+3)
        print_frame(sys._current_frames())

    print_frame(sys._current_frames())
    g(a*2)

f(3)
Github repository about-python, path: /standard-library/sys/_call-stack/_current_frames.py

See also

sys, sys._getframe().
The traceback module

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1745044550, '3.129.253.54', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Python/standard-library/sys/_call-stack/_current_frames(73): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78