The io_utils.py module#

Summary#

write_or_return

Write to buffer or returns a string.

Description#

Utils for i/o.

Module detail#

io_utils.write_or_return(buf: TextIO | None, func: Callable) str | None#

Write to buffer or returns a string.

Uses the callable func to write. If buf is None, then the function will create a string buffer before calling func and return the result as a string.