def _open_text ( fname , * * kwargs ) : if PY3 : kwargs . setdefault ( 'encoding' , ENCODING ) kwargs . setdefault ( 'errors' , ENCODING_ERRS ) return open ( fname , "rt" , * * kwargs )
try multiple encodings pythons while opening a file
On Python 3 opens a file in text mode by using fs encoding and a proper en / decoding errors handler . On Python 2 this is just an alias for open ( name rt ) .
def _open_text(fname, **kwargs):
    """On Python 3 opens a file in text mode by using fs encoding and
    a proper en/decoding errors handler.
    On Python 2 this is just an alias for open(name, 'rt').
    """
    if PY3:
        kwargs.setdefault('encoding', ENCODING)
        kwargs.setdefault('errors', ENCODING_ERRS)
    return open(fname, "rt", **kwargs)