[Python-ideas] .from and .to instead of .encode and .decode

Chris Angelico rosuav at gmail.com
Mon Mar 16 17:55:00 CET 2015


On Tue, Mar 17, 2015 at 3:41 AM, Chris Barker <chris.barker at noaa.gov> wrote:
> I suppose we could have used "decode_from" and "encode_to" in the first
> place to be really clear, but I don't think it's worth making that change
> now.

I don't think it'd help much. It'd just be noise words, at best. What
you're doing is encoding or decoding using a particular scheme. What
scheme? That's the parameter. You're encoding to bytes and decoding to
text; and in order to perform that transformation, you use a standard
technique by the name of UTF-8. The result of "spam".encode("UTF-8")
is not a UTF-8, it's a stream of bytes. So there'd be just as much
confusion the other way around.

*shrug*

ChrisA


More information about the Python-ideas mailing list