opennmt/utils/misc.py
def print_as_bytes(text, stream=None):
    """Prints a string as bytes to not rely on :obj:`stream` default encoding.

    Args:
      text: The text to print.
      stream: The stream to print to (``sys.stdout`` if not set).
    """
    if stream is None:
        stream = sys.stdout
    write_buffer = stream.buffer if hasattr(stream, "buffer") else stream
    write_buffer.write(tf.compat.as_bytes(text))
    write_buffer.write(b"\n")
    stream.flush()
Prints a string as bytes to not rely on :obj:`stream` default encoding.

    Args:
      text: The text to print.
      stream: The stream to print to (``sys.stdout`` if not set).
    
Prints a string as bytes to not rely on :obj:`stream` default encoding.
Prints a string as bytes to not rely on : obj : ` stream ` default encoding .
def print_as_bytes(text, stream=None):
    if stream is None:
        stream = sys.stdout
    write_buffer = stream.buffer if hasattr(stream, "buffer") else stream
    write_buffer.write(tf.compat.as_bytes(text))
    write_buffer.write(b"\n")
    stream.flush()
def print_as_bytes ( text , stream = None ) : if stream is None : stream = sys . stdout write_buffer = stream . buffer if hasattr ( stream , "buffer" ) else stream write_buffer . write ( tf . compat . as_bytes ( text ) ) write_buffer . write ( b"\n" ) stream . flush ( )
Prints a string as bytes to not rely on :obj:`stream` default encoding.
Prints a string as bytes to not rely on : obj : ` stream ` default encoding .
"""Prints a string as bytes to not rely on :obj:`stream` default encoding.

    Args:
      text: The text to print.
      stream: The stream to print to (``sys.stdout`` if not set).
    """
text
The text to print.
The text to print .
stream
The stream to print to (``sys.stdout`` if not set).
The stream to print to ( ` ` sys . stdout ` ` if not set ) .