[Python-Dev] PEP 332 revival in coordination with pep 349? [ Was:Re: release plan for 2.5 ?]
Greg Ewing
greg.ewing at canterbury.ac.nz
Wed Feb 15 02:30:29 CET 2006
Guido van Rossum wrote:
> The only remaining question is what if anything to do with an
> encoding argment when the first argument is of type str...)
From what you said earlier about str in 2.x being
interpretable as a unicode string which contains
only ascii, it seems to me that if you say
bytes(s, encoding)
where s is a str, then by the presence of the encoding
argument you're saying that you want s to be treated as
unicode and encoded using the specified encoding.
So the result should be the same as
bytes(u, encoding)
where u is a unicode string containing the same code
points as s. This implies that it should be an error
if s contains non-ascii characters.
This interpretation would satisfy the requirement for
a single call signature covering both unicode and
str-used-as-ascii-characters, while providing a
different call signature (without encoding) for
str-used-as-bytes.
--
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury, | Carpe post meridiam! |
Christchurch, New Zealand | (I'm not a morning person.) |
greg.ewing at canterbury.ac.nz +--------------------------------------+
More information about the Python-Dev
mailing list