Antoine Pitrou <solip...@pitrou.net> wrote:

> Le mercredi 09 juin 2010 à 12:38 +0100, Michael Foord a écrit :
> > On 09/06/2010 12:35, Antoine Pitrou wrote:
> > > On Wed, 09 Jun 2010 10:41:29 +0200
> > > "M.-A. Lemburg"<m...@egenix.com>  wrote:
> > >    
> > >> The above example will read:
> > >>
> > >>      >>>  b'abc'.transform("hex")
> > >>      b'616263'
> > >>      >>>  b'616263'.untranform("hex")
> > >>      b'abc'
> > >>      
> > > This doesn't look right to me. Hex-encoded "data" is really text (it's
> > > a textual representation of binary, and isn't often used as an opaque
> > > binary transport encoding).
> > > Of course, this is not necessarily so for all codecs. For
> > > base64-encoded data, for example, it is debatable whether you want it
> > > as ASCII bytes or unicode text.
> > >    
> > 
> > But in both cases you probably want bytes -> bytes and str -> str. If 
> > you want text out then put text in, if you want bytes out then put bytes in.
> 
> No, I don't think so. If I'm using hex "encoding", it's because I want
> to see a text representation of some arbitrary bytestring (in order to
> display it inside another piece of text, for example).
> In other words, the purpose of hex is precisely to give a textual
> display of non-textual data.

Yes.  And base64, and quoted-printable, etc.

Bill
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to