Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Exception Frame Local Variable Values

DZone's Guide to

Exception Frame Local Variable Values

·
Free Resource
Returns dictionary with local variable content from frame where exception was raised


def getExceptionFrameLocals():
    retVal = {}

    if sys.exc_info():
        trace = sys.exc_info()[2]
        while trace.tb_next:
            trace = trace.tb_next
        retVal = trace.tb_frame.f_locals

    return retVal

Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}