[Python-3000] Thoughts on new I/O library and bytecode
greg.ewing at canterbury.ac.nz
Tue Feb 27 01:39:49 CET 2007
Josiah Carlson wrote:
> Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> I think it's a bad idea to choose a representation with any format that
> isn't able to do the eval(repr(obj)) loop.
The intention was for that to be a valid literal
syntax as well.
> It may be the case
> that b"stuff" is the most concise and reasonable repr form...
I can only see it being the most concise when most of
the bytes can be meaningfully interpreted as characters.
Otherwise it's full of \xyy escapes, making it up to
twice as long as necessary and harder to read.
I can't help feeling the people arguing for b"..." as the
repr format haven't really accepted the fact that text and
binary data will be distinct things in py3k, and are thinking
of bytes as being a replacement for the old string type. But
that's not true -- most of the time, *unicode* will be the
replacement for str when it is used to represent characters,
and bytes will mostly be used only for non-text.
I know that there will be exceptions, such as when writing
code to deal with raw SMTP connections and such like. But
how often do people write code like that? Usually it's
written once and put in a library. I think these cases will
be in the minority.
> If you want all hex, use the .hex() method described in the PEP.
That seems back-to-front to me. The default repr should
not be making assumptions about the meaning of the bytes.
It would make more sense to have a .chars() method or
something for when you want it interpreted that way.
More information about the Python-3000