(value)
Override standard display hook to use non-locale encoding
Override standard display hook to use non-locale encoding
Override standard display hook to use non - locale encoding
def displayhook(value):
    """Override standard display hook to use non-locale encoding"""
    if value is None:
        return
    # Set '_' to None to avoid recursion
    builtins._ = None
    text = repr(value)
    try:
        sys.stdout.write(text)
    except UnicodeEncodeError:
        # let's use ascii while utf8-bmp codec doesn't present
        encoding = 'ascii'
        bytes = text.encode(encoding, 'backslashreplace')
        text = bytes.decode(encoding, 'strict')
        sys.stdout.write(text)
    sys.stdout.write("\n")
    builtins._ = value
def displayhook ( value ) : if value is None : return # Set '_' to None to avoid recursion builtins . _ = None text = repr ( value ) try : sys . stdout . write ( text ) except UnicodeEncodeError : # let's use ascii while utf8-bmp codec doesn't present encoding = 'ascii' bytes = text . encode ( encoding , 'backslashreplace' ) text = bytes . decode ( encoding , 'strict' ) sys . stdout . write ( text ) sys . stdout . write ( "\n" ) builtins . _ = value