Re: str(bytes) in Python 3.0

2008-04-13 Thread Kay Schluehr
On 13 Apr., 09:24, Carl Banks <[EMAIL PROTECTED]> wrote: > On Apr 12, 11:51 am, Kay Schluehr <[EMAIL PROTECTED]> wrote: > > > On 12 Apr., 16:29, Carl Banks <[EMAIL PROTECTED]> wrote: > > > > > And making an utf-8 encoding default is not possible without writing a > > > > new function? > > > > I bel

Re: str(bytes) in Python 3.0

2008-04-13 Thread Carl Banks
On Apr 12, 11:51 am, Kay Schluehr <[EMAIL PROTECTED]> wrote: > On 12 Apr., 16:29, Carl Banks <[EMAIL PROTECTED]> wrote: > > > > And making an utf-8 encoding default is not possible without writing a > > > new function? > > > I believe the Zen in effect here is, "In the face of ambiguity, refuse > >

Re: str(bytes) in Python 3.0

2008-04-12 Thread Terry Reedy
"John Roth" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | On Apr 12, 8:52 am, [EMAIL PROTECTED] (John J. Lee) wrote: | > Christian Heimes <[EMAIL PROTECTED]> writes: | > > Gabriel Genellina schrieb: | > >> On the last line, str(x), I would expect 'abc' - same as str(x, 'ascii') |

Re: str(bytes) in Python 3.0

2008-04-12 Thread Gabriel Genellina
En Sat, 12 Apr 2008 11:25:59 -0300, Martin v. Löwis <[EMAIL PROTECTED]> escribió: >> And making an utf-8 encoding default is not possible without writing a >> new function? > > There is no default encoding anymore in Python 3. This is by design, > learning from the problems in Python 2.x. So sy

Re: str(bytes) in Python 3.0

2008-04-12 Thread Steve Holden
Dan Bishop wrote: > On Apr 12, 9:29 am, Carl Banks <[EMAIL PROTECTED]> wrote: >> On Apr 12, 10:06 am, Kay Schluehr <[EMAIL PROTECTED]> wrote: >> >>> On 12 Apr., 14:44, Christian Heimes <[EMAIL PROTECTED]> wrote: Gabriel Genellina schrieb: > On the last line, str(x), I would expect 'abc' -

Re: str(bytes) in Python 3.0

2008-04-12 Thread Dan Bishop
On Apr 12, 9:29 am, Carl Banks <[EMAIL PROTECTED]> wrote: > On Apr 12, 10:06 am, Kay Schluehr <[EMAIL PROTECTED]> wrote: > > > On 12 Apr., 14:44, Christian Heimes <[EMAIL PROTECTED]> wrote: > > > > Gabriel Genellina schrieb: > > > > > On the last line, str(x), I would expect 'abc' - same as str(x,

Re: str(bytes) in Python 3.0

2008-04-12 Thread John Roth
On Apr 12, 8:52 am, [EMAIL PROTECTED] (John J. Lee) wrote: > Christian Heimes <[EMAIL PROTECTED]> writes: > > Gabriel Genellina schrieb: > >> On the last line, str(x), I would expect 'abc' - same as str(x, 'ascii') > >> above. But I get the same as repr(x) - is this on purpose? > > > Yes, it's on p

Re: str(bytes) in Python 3.0

2008-04-12 Thread Lorenzo Gatti
On Apr 12, 5:51 pm, Kay Schluehr <[EMAIL PROTECTED]> wrote: > On 12 Apr., 16:29, Carl Banks <[EMAIL PROTECTED]> wrote: > > > > And making an utf-8 encoding default is not possible without writing a > > > new function? > > > I believe the Zen in effect here is, "In the face of ambiguity, refuse > >

Re: str(bytes) in Python 3.0

2008-04-12 Thread Kay Schluehr
On 12 Apr., 16:29, Carl Banks <[EMAIL PROTECTED]> wrote: > > And making an utf-8 encoding default is not possible without writing a > > new function? > > I believe the Zen in effect here is, "In the face of ambiguity, refuse > the temptation to guess." How do you know if the bytes are utf-8 > enc

Re: str(bytes) in Python 3.0

2008-04-12 Thread Christian Heimes
John J. Lee schrieb: > Why hasn't the one-argument str(bytes_obj) been designed to raise an > exception in Python 3? See for yourself: $ ./python Python 3.0a4+ (py3k:0, Apr 11 2008, 15:31:31) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits"

Re: str(bytes) in Python 3.0

2008-04-12 Thread Christian Heimes
Carl Banks schrieb: > I believe the Zen in effect here is, "In the face of ambiguity, refuse > the temptation to guess." How do you know if the bytes are utf-8 > encoded? Indeed > I'm not sure if str() returning the repr() of a bytes object (when not > passed an encoding) is the right thing, but

Re: str(bytes) in Python 3.0

2008-04-12 Thread John J. Lee
Christian Heimes <[EMAIL PROTECTED]> writes: > Gabriel Genellina schrieb: >> On the last line, str(x), I would expect 'abc' - same as str(x, 'ascii') >> above. But I get the same as repr(x) - is this on purpose? > > Yes, it's on purpose but it's a bug in your application to call str() on > a byt

Re: str(bytes) in Python 3.0

2008-04-12 Thread Carl Banks
On Apr 12, 10:06 am, Kay Schluehr <[EMAIL PROTECTED]> wrote: > On 12 Apr., 14:44, Christian Heimes <[EMAIL PROTECTED]> wrote: > > > Gabriel Genellina schrieb: > > > > On the last line, str(x), I would expect 'abc' - same as str(x, 'ascii') > > > above. But I get the same as repr(x) - is this on pur

Re: str(bytes) in Python 3.0

2008-04-12 Thread Martin v. Löwis
> And making an utf-8 encoding default is not possible without writing a > new function? There is no default encoding anymore in Python 3. This is by design, learning from the problems in Python 2.x. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: str(bytes) in Python 3.0

2008-04-12 Thread Kay Schluehr
On 12 Apr., 14:44, Christian Heimes <[EMAIL PROTECTED]> wrote: > Gabriel Genellina schrieb: > > > On the last line, str(x), I would expect 'abc' - same as str(x, 'ascii') > > above. But I get the same as repr(x) - is this on purpose? > > Yes, it's on purpose but it's a bug in your application to ca

Re: str(bytes) in Python 3.0

2008-04-12 Thread Christian Heimes
Gabriel Genellina schrieb: > On the last line, str(x), I would expect 'abc' - same as str(x, 'ascii') > above. But I get the same as repr(x) - is this on purpose? Yes, it's on purpose but it's a bug in your application to call str() on a bytes object or to compare bytes and unicode directly. Sev

str(bytes) in Python 3.0

2008-04-11 Thread Gabriel Genellina
Hello Is this the intended behavior? Python 3.0a4+ (py3k, Apr 12 2008, 02:53:16) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> x = b"abc" >>> repr(x) "b'abc'" >>> str(x,"ascii") 'abc' >>> str(x,"utf-8") 'abc' >>> str(x) "b'abc'"