Skip to content

print_raw function for writing bytes out on Python 3 #5

Description

@jlevy

Often people print bytes out and it looks ugly in Python 3.

Convert something like this to handle raw writing in Python 3 and with a file= argument for multiple streams. Can fallback to regular print in Python 2.

def print_raw(bytes):
  """Print bytes, preserving binary chars for color/CURSES/etc on command line."""
  sys.stdout.buffer.write(bytes)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions