[Python-3000] Does bytes() need to support bytes(<str>, <encoding>)?
Guido van Rossum
guido at python.org
Tue Aug 28 17:21:50 CEST 2007
On 8/28/07, Barry Warsaw <barry at python.org> wrote:
> On Aug 27, 2007, at 11:20 PM, Guido van Rossum wrote:
>
> > But I don't see the point of defaulting to raw-unicode-escape --
> > what's the use case for that? I think you should just explicitly say
> > s.encode('raw-unicode-escape') where you need that. Any reason you
> > can't?
>
> Nope. So what would bytes(s) do?
Raise TypeError (when s is a str). The argument to bytes() must be
either an int (then it creates a zero-filled bytes bytes array of that
length) or an iterable of ints (then it creates a bytes array
initialized with those ints -- if any int is out of range, an
exception is raised, and also if any value is not an int).
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list