[Python-Dev] Python3 "complexity"
Stephen J. Turnbull
stephen at xemacs.org
Fri Jan 10 07:13:47 CET 2014
INADA Naoki writes:
> latin1 is OK but is it Pythonic?
Yes. EIBTI, including being explicit that you're doing something that
has semantics that you are ignoring but may come back to bite you or
somebody who naively uses your module.
There's nothing un-Pythonic about using potentially dangerous idioms.
We assume that you know what you are doing and either have taken
measures to trap exceptional cases or are willing to accept the risk
of an unhandled exception.
> I've posted suggestion about add 'bytes' as a alias for 'latin1'.
Unpythonic. Such alternative names hide the fact that there are
semantics that you may not want. Only the programmer can know whether
it's safe. If you want an ascii-compatible and space-efficient
representation that is safe even if the bytestream is something you
don't expect, you need to do something like I proposed. If you don't
need efficiency, (encoding='ascii', errors='surrogateescape') is the
way to go. But these still don't provide convenient interpolation of
binary data, as we discovered earlier.
More information about the Python-Dev