traceback#

traceback(exc=None, value=None, tb=None, verbose=False, *args, **kwargs)[source]#

Shortcut for accessing the traceback

Alias for traceback.format_exc().

If no argument is provided, then use the last exception encountered.

Args:

exc (Exception, tuple/list, or type): the exception to get the traceback from value (Exception): the actual exception tb (Traceback): the traceback verbose (bool): whether to print the exception

Examples:

# Use automatic exception info
mylist = [0,1]
try:
    mylist[2]
except:
    print(f'Error: {sc.traceback()}')

# Supply exception manually (also illustrating sc.tryexcept())
with sc.tryexcept() as te1:
    dict(a=3)['b']

with sc.tryexcept() as te2:
    [0,1][2]

tb1 = sc.traceback(te1.exception)
tb2 = sc.traceback(te2.exception)
print(f'Tracebacks were:

{tb1} {tb2}’)