libb.stream

Functions

is_tty()

Check if running in a terminal.

stream_is_tty(somestream)

Check if a stream is running in a terminal.

is_tty()[source]

Check if running in a terminal.

Returns True if: - Running under pytest (always True for testing) - stdin is a TTY (interactive input) - stderr is a TTY (logger output visible in terminal)

Returns:

True if in a terminal environment.

Return type:

bool

stream_is_tty(somestream)[source]

Check if a stream is running in a terminal.

Parameters:

somestream – Stream to check (typically sys.stdout).

Returns:

True if stream is a TTY.

Return type:

bool

Example:

>>> import io
>>> stream_is_tty(io.StringIO())
False