[Python-ideas] Add encoding attribute to bytes

Georg Brandl g.brandl at gmx.net
Tue Nov 10 09:20:15 CET 2009

Terry Reedy schrieb:
> Georg Brandl wrote:
>>> What I do not know if it is feasible to give an immutable instance of a 
>>> builtin class a mutable attribute slot.
>> As soon as you can mutate an instance, it is not an immutable type anymore.
>> Calling it "immutable" despite will cause trouble.  (The same bytes instance
>> could be used somewhere else transparently, e.g. as a function default
>> argument, or cached as a constant local.)
> OK, scratch that implementation of my idea.
>> As for the usefulness, I often have to work with proprietary communication
>> protocols between computer and devices, and there the bytes have no encoding
>> whatsoever
> Random bits? It seems to me that protocol means some sort of encoding, 
> formatting, or structuring, some sort of agreed on interpretation, even 
> if private.

Sure, but nothing you could map entirely onto a string of Unicode characters.


More information about the Python-ideas mailing list