print¶
- print(fmt, *args, **kwargs)[source]¶
A
qjit()
compatible print function for printing values at runtime.This print function allows printing of values at runtime, unlike usage of standard Python
print
which will print values at program capture/compile time.debug.print
is a minimal wrapper aroundcallback()
which calls Python’sbuiltins.print
function, and thus will use the same formatting styles as Python’s built-in print function.- Parameters
fmt (str) – The string to be printed. Note that this may also be a format string used to format input arguments (for example
cost={x}
), similar to those permitted bystr.format
. See the Python docs on string formatting and format string syntax.**args – Arguments to be passed to the format string.
**kwargs – Keyword arguments to be passed to the format string.
See also
Example
@qjit def f(a, b, c): debug.print("c={c} b={b} a={a}", a=a, b=b, c=c)
>>> f(1, 2, 3) c=3 b=2 a=1
Note
Using Python f-strings as the
fmt
string will not work as expected since they will be treated as Python objects. This means that array values embedded in them will have their compile-time representation printed, instead of actual data.