This is a development version (9.18.0.dev) and may be unstable.Go to latest (9.17.0)
{ } Raw JSON

bundles / IPython 9.18.0.dev / IPython / utils / encoding / get_stream_enc

function

IPython.utils.encoding:get_stream_enc

source: /IPython/utils/encoding.py:23

Signature

def get_stream_enc(stream: Any, default: str | None = None) → str | None

Summary

Return the given stream's encoding or a default.

Extended Summary

There are cases where sys.std* might not actually be a stream, so check for the encoding attribute prior to returning it, and return a default if it doesn't exist or evaluates as False. default is None if not provided.

Aliases

  • IPython.utils.encoding.get_stream_enc