Guido van Rossum wrote: > On 2/13/06, Phillip J. Eby <[EMAIL PROTECTED]> wrote: >> At 09:55 AM 2/13/2006 -0800, Guido van Rossum wrote: >>> One recommendation: for starters, I'd much rather see the bytes type >>> standardized without a literal notation. There should be are lots of >>> ways to create bytes objects from string objects, with specific >>> explicit encodings, and those should suffice, at least initially. >>> >>> I also wonder if having a b"..." literal would just add more confusion >>> -- bytes are not characters, but b"..." makes it appear as if they >>> are. >> Why not just have the constructor be: >> >> bytes(initializer [,encoding]) >> >> Where initializer must be either an iterable of suitable integers, or a >> unicode/string object. If the latter (i.e., it's a basestring), the >> encoding argument would then be required. Then, there's no need for >> special codec support for the bytes type, since you call bytes on the thing >> to be encoded. And of course, no need for a 'b' literal. > > It'd be cruel and unusual punishment though to have to write > > bytes("abc", "Latin-1") > > I propose that the default encoding (for basestring instances) ought > to be "ascii" just like everywhere else. (Meaning, it should really be > the system default encoding, which defaults to "ascii" and is > intentionally hard to change.)
We're talking about Py3k here: "abc" will be a Unicode string, so why restrict the conversion to 7 bits when you can have 8 bits without any conversion problems ? While we're at it: I'd suggest that we remove the auto-conversion from bytes to Unicode in Py3k and the default encoding along with it. In Py3k the standard lib will have to be Unicode compatible anyway and string parser markers like "s#" will have to go away as well, so there's not much need for this anymore. (Maybe a bit radical, but I guess that's what Py3k is meant for.) -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Feb 13 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: _______________________________________________ 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