[Python-ideas] Adding 'bytes' as alias for 'latin_1' codec.

INADA Naoki songofacandy at gmail.com
Fri May 27 04:02:52 CEST 2011


On Fri, May 27, 2011 at 7:26 AM, Terry Reedy <tjreedy at udel.edu> wrote:
> On 5/26/2011 7:17 AM, Masklinn wrote:
>>
>> Considering the original use case,
>
> to prefix ascii-encoded numbers to lines in an unknown but ascii-compatible
> encoding*,
> and considering the responses since my last post, I have changed from -0 to
> -1 to the alias proposal.
>
> 1. The use case does not need the fake decoding and is better off without
> it.
> 2. I suspect the uses cases where fake decoding is both needed and
> sufficient are relatively rare.
> 3. Fake decoding is dangerous (Lemburg).
> 4. People who know enough to use it safely should already know about how
> latin-1 relates to unicode, and therefore do not need an alias.
> 5. Other people should not be encouraged to use it as a fake.

OK, I understand that using 'latin1' is just a hack and not Pythonic way.

Then, I hope bytes has a fast and efficient "format" method like:
>>> b'{0} {1}'.format(23, b'foo')  # accepts int, float, bytes, bool, None
23 foo
>>> b'{0}'.format('foo')  # raises TypeError for other types.
TypeError

And line buffering in binary mode is also nice.

> *I meant to ask earlier whether there are ascii-incompatible encodings for
> which the original code and my revision would not work. I gather from the
> responses that yes, there are some.
>
> --
> Terry Jan Reedy
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>



-- 
INADA Naoki  <songofacandy at gmail.com>



More information about the Python-ideas mailing list