[Email-SIG] [Python-Dev] Dropping bytes "support" in json

Glenn Linderman v+python at g.nevcal.com
Fri Apr 10 20:00:54 CEST 2009


On approximately 4/10/2009 9:56 AM, came the following characters from 
the keyboard of Barry Warsaw:
> On Apr 10, 2009, at 1:19 AM, glyph at divmod.com wrote:
>> On 02:38 am, barry at python.org wrote:
>>> So, what I'm really asking is this.  Let's say you agree that there 
>>> are use cases for accessing a header value as either the raw encoded 
>>> bytes or the decoded unicode.  What should this return:
>>>
>>> >>> message['Subject']
>>>
>>> The raw bytes or the decoded unicode?
>>
>> My personal preference would be to just get deprecate this API, and 
>> get rid of it, replacing it with a slightly more explicit one.
>>
>>   message.headers['Subject']
>>   message.bytes_headers['Subject']
>
> This is pretty darn clever Glyph.  Stop that! :)
>
> I'm not 100% sure I like the name .bytes_headers or that .headers 
> should be the decoded header (rather than have .headers return the 
> bytes thingie and say .decoded_headers return the decoded thingies), 
> but I do like the general approach.

If one name has to be longer than the other, it should be the bytes 
version.  Real user code is more likely to want to use the text version, 
and hopefully there will be more of that type of code than 
implementations using bytes.

Of course, one could use message.header and message.bythdr and they'd be 
the same length.


-- 
Glenn -- http://nevcal.com/
===========================
A protocol is complete when there is nothing left to remove.
-- Stuart Cheshire, Apple Computer, regarding Zero Configuration Networking



More information about the Email-SIG mailing list