Tracer

Warning

The Torii API reference is a work in progress and we are actively working on improving it, however it may be deficient or missing in places.

torii.util.tracer.get_src_loc(src_loc_at: int = 0) tuple[str, int]

Get the file and line number from the given frame on the call stack.

Parameters:

src_loc_at (int) – The frame above this call in which to get the file and line number from. (default: 0)

Important

When passing 0, the resulting frame is the one directly above the call site, i.e. the line that the function this was called in was invoked on.

Returns:

The file name and line number of the given stack frame.

Return type:

SrcLoc

torii.util.tracer.get_var_name(depth: int = 2, default: str | object = <object object>) str

Get the variable name from an assignment up the call stack.

Parameters:
  • depth (int) – The number of stack frames above us to look. (default: 2)

  • default (str | object) – The default name of the variable if it’s not found. (default: _raise_exception)

Important

The default value of depth is set so that the assignment of the result of the current call frame will be used.

Raises:

NameNotFound – When default is set to the default value of _raise_exception and the name is not found.

exception torii.util.tracer.NameNotFound