[Python-ideas] .from and .to instead of .encode and .decode
anatoly techtonik
techtonik at gmail.com
Thu Mar 5 14:40:05 CET 2015
Hi,
While looking at the code like:
'os': sysinfo['os'].decode('utf-8'),
'hostname': sysinfo['hostname'].decode('utf-8'),
I can't really read if the result will be unicode or binary string in
utf-8. It would be more convenient for readability to have these
instead:
bytes.from(encoding) -> unicode
unicode.to(encoding) -> bytes
.encode/.decode are confusing, because it Python 2 it was:
str.encode(encoding) -> str
str.decode(encoding) -> str
with no encoding info attached.
--
anatoly t.
More information about the Python-ideas
mailing list