[I18n-sig] Binary data b"strings" (Pre-PEP: Proposed Python
Character Model)
M.-A. Lemburg
mal@lemburg.com
Thu, 08 Feb 2001 17:33:49 +0100
Toby Dickenson wrote:
>
> > I once proposed to use a new qualifier for binary data, e.g.
> > b"binary data" or d"binary data". Don't remember the outcome though
> > as this was during the heated debate over how to do Unicode right
> > earlier last year.
> >
> > Perhaps the only new type we need is an easy to manage
> > binary data type that behaves very much like the old-school
> > strings.
>
> Yes, that all sounds like a good idea. I think changing some "strings" to
> b"strings" is a necessary step on the way to 'python -U'.
>
> I would want to avoid the need for a 2.0-style 'default encoding', so I
> suggest it shouldnt be possible to mix this type with other strings:
>
> >>> "1"+b"2"
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> TypeError: cannot add type "binary" to string
> >>> "3"==b"3"
> 0
Right. This will cause people to rethink whether they are
using the object for text data or binary data. I still think that
at the interface level, b"" and "" should be treated the same (except
that b""-strings should not implement the char buffer interface).
OTOH, these b""-strings should implement the same methods as the
array type and probably seemlessly interact with it too. I don't
know which type should be considered "better" in coercion
though, b""-strings or arrays (I guess b""-strings).
(Waiting for someone to tear down the idea... ;-)
--
Marc-Andre Lemburg
______________________________________________________________________
Company: http://www.egenix.com/
Consulting: http://www.lemburg.com/
Python Pages: http://www.lemburg.com/python/