Re: Byte type?

2009-03-12 Thread Scott David Daniels
John Nagle wrote: Martin v. Löwis wrote: Please don't call something dumb that you don't fully understand ...- do you have to convert twice? Depends on how you write your code. If you use the bytearray type (which John didn't, despite his apparent believe that he did), then no conversion

Re: Byte type?

2009-03-12 Thread ajaksu
On Feb 15, 3:10 am, John Nagle na...@animats.com wrote: With bytearray, the element type is considered to be unsigned byte, or so says PEP 3137: The element data type is always 'B' (i.e. unsigned byte). Let's try: Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit

Re: Byte type?

2009-03-12 Thread ajaksu
On Feb 24, 1:21 am, John Nagle na...@animats.com wrote:      According to PEP 3137, there should be no distinction between the two for read purposes.  In 2.6, there is.  That's a bug. No, it's not. It's well documented: http://docs.python.org/whatsnew/2.6.html#pep-3112-byte-literals If that's

Re: Byte type?

2009-02-24 Thread Paddy O'Loughlin
2009/2/24 John Nagle na...@animats.com: Martin v. Löwis wrote: Please don't call something dumb that you don't fully understand. It's offenses the people who have spent lots of time developing Python -- personal, unpaid and voluntary time!   Some of the people involved are on Google's

Re: Byte type?

2009-02-23 Thread John Nagle
Martin v. Löwis wrote: Please don't call something dumb that you don't fully understand. It's offenses the people who have spent lots of time developing Python -- personal, unpaid and voluntary time! Some of the people involved are on Google's payroll. Crying out; Please do not criticise

Re: Byte type?

2009-02-23 Thread Martin v. Löwis
Depends on how you write your code. If you use the bytearray type (which John didn't, despite his apparent believe that he did), then no conversion additional conversion is needed. According to PEP 3137, there should be no distinction between the two for read purposes. In 2.6, there

Re: Byte type?

2009-02-22 Thread Hendrik van Rooyen
Christian Heimes liss.de wrote: John Nagle wrote If bytes, a new keyword, works differently in 2.6 and 3.0, that was really dumb. There's no old code using bytes. So converting code to 2.6 means it has to be converted AGAIN for 3.0. That's a good reason to ignore 2.6 as

Re: Byte type?

2009-02-22 Thread Matthew Woodcraft
Hendrik van Rooyen m...@microcorp.co.za writes: Christian Heimes liss.de wrote: on the surface JN has a point - If you have to go through two conversions, then 2.6 does not achieve what it appears to set out to do. So the issue is simple: - do you have to convert twice? - If yes - why?

Re: Byte type?

2009-02-22 Thread Christian Heimes
Hendrik van Rooyen wrote: Christian Heimes liss.de wrote: John Nagle wrote If bytes, a new keyword, works differently in 2.6 and 3.0, that was really dumb. There's no old code using bytes. So converting code to 2.6 means it has to be converted AGAIN for 3.0. That's a good reason

Re: Byte type?

2009-02-22 Thread Martin v. Löwis
Please don't call something dumb that you don't fully understand. It's offenses the people who have spent lots of time developing Python -- personal, unpaid and voluntary time! Crying out; Please do not criticise me, I am doing it for free! does not justify delivering sub standard work -

Re: Byte type?

2009-02-21 Thread Steve Holden
John Nagle wrote: Steve Holden wrote: John Nagle wrote: Benjamin Kaplan wrote: On Sun, Feb 15, 2009 at 11:57 AM, John Nagle na...@animats.com wrote: ...Re bytes not behaving as documented in 2.6: That's indeed how Python 2.6 works. But that's not how PEP 3137 says it's supposed to

Re: Byte type?

2009-02-21 Thread John Nagle
Steve Holden wrote: John Nagle wrote: Steve Holden wrote: John Nagle wrote: Benjamin Kaplan wrote: On Sun, Feb 15, 2009 at 11:57 AM, John Nagle na...@animats.com wrote: ...Re bytes not behaving as documented in 2.6: That's indeed how Python 2.6 works. But that's not how PEP 3137 says

Re: Byte type?

2009-02-21 Thread Christian Heimes
John Nagle wrote If bytes, a new keyword, works differently in 2.6 and 3.0, that was really dumb. There's no old code using bytes. So converting code to 2.6 means it has to be converted AGAIN for 3.0. That's a good reason to ignore 2.6 as defective. Please don't call something dumb

Re: Byte type?

2009-02-21 Thread Benjamin Kaplan
On Sat, Feb 21, 2009 at 12:21 PM, John Nagle na...@animats.com wrote: Steve Holden wrote: John Nagle wrote: Steve Holden wrote: John Nagle wrote: Benjamin Kaplan wrote: On Sun, Feb 15, 2009 at 11:57 AM, John Nagle na...@animats.com wrote: ...Re bytes not behaving as documented in

Re: Byte type?

2009-02-20 Thread John Nagle
Steve Holden wrote: John Nagle wrote: Benjamin Kaplan wrote: On Sun, Feb 15, 2009 at 11:57 AM, John Nagle na...@animats.com wrote: ...Re bytes not behaving as documented in 2.6: That's indeed how Python 2.6 works. But that's not how PEP 3137 says it's supposed to work. Guido: I

Re: Byte type?

2009-02-15 Thread Steve Holden
Erik Max Francis wrote: John Nagle wrote: With bytearray, the element type is considered to be unsigned byte, or so says PEP 3137: The element data type is always 'B' (i.e. unsigned byte). Let's try: Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on

Re: Byte type?

2009-02-15 Thread Benjamin Peterson
Steve Holden steve at holdenweb.com writes: Beware, also, that in 2.6 the bytes type is essentially an ugly hack to enable easier forward compatibility with the 3.X series ... It's not an ugly hack. It just isn't all that you might hope it'd live up to be. --

Re: Byte type?

2009-02-15 Thread Steve Holden
Benjamin Peterson wrote: Steve Holden steve at holdenweb.com writes: Beware, also, that in 2.6 the bytes type is essentially an ugly hack to enable easier forward compatibility with the 3.X series ... It's not an ugly hack. It just isn't all that you might hope it'd live up to be. I take

Re: Byte type?

2009-02-15 Thread John Nagle
Benjamin Peterson wrote: Steve Holden steve at holdenweb.com writes: Beware, also, that in 2.6 the bytes type is essentially an ugly hack to enable easier forward compatibility with the 3.X series ... It's not an ugly hack. It just isn't all that you might hope it'd live up to be. The

Re: Byte type?

2009-02-15 Thread Benjamin Kaplan
On Sun, Feb 15, 2009 at 11:57 AM, John Nagle na...@animats.com wrote: Benjamin Peterson wrote: Steve Holden steve at holdenweb.com writes: Beware, also, that in 2.6 the bytes type is essentially an ugly hack to enable easier forward compatibility with the 3.X series ... It's not an ugly

Re: Byte type?

2009-02-15 Thread Mark Tolonen
John Nagle na...@animats.com wrote in message news:499841bf$0$1624$742ec...@news.sonic.net... Benjamin Peterson wrote: Steve Holden steve at holdenweb.com writes: Beware, also, that in 2.6 the bytes type is essentially an ugly hack to enable easier forward compatibility with the 3.X series

Re: Byte type?

2009-02-15 Thread John Nagle
Benjamin Kaplan wrote: On Sun, Feb 15, 2009 at 11:57 AM, John Nagle na...@animats.com wrote: Benjamin Peterson wrote: Because b'x' is NOT a bytearray. It is a bytes object. When you actually use a bytearray, it behaves like you expect. type(b'x') class 'bytes' type(bytearray(b'x'))

Re: Byte type?

2009-02-15 Thread John Nagle
Benjamin Kaplan wrote: On Sun, Feb 15, 2009 at 11:57 AM, John Nagle na...@animats.com wrote: Benjamin Peterson wrote: Because b'x' is NOT a bytearray. It is a bytes object. When you actually use a bytearray, it behaves like you expect. type(b'x') class 'bytes' type(bytearray(b'x'))

Re: Byte type?

2009-02-15 Thread Steve Holden
John Nagle wrote: Benjamin Kaplan wrote: On Sun, Feb 15, 2009 at 11:57 AM, John Nagle na...@animats.com wrote: Benjamin Peterson wrote: Because b'x' is NOT a bytearray. It is a bytes object. When you actually use a bytearray, it behaves like you expect. type(b'x') class 'bytes'

Re: Byte type?

2009-02-14 Thread Lie Ryan
On Sat, 14 Feb 2009 22:10:41 -0800, John Nagle wrote: xx = b'x' Isn't this creating a regular byte? Shouldn't creation of bytearray be: xx = bytearray(b'x') -- http://mail.python.org/mailman/listinfo/python-list

Re: Byte type?

2009-02-14 Thread Erik Max Francis
John Nagle wrote: With bytearray, the element type is considered to be unsigned byte, or so says PEP 3137: The element data type is always 'B' (i.e. unsigned byte). Let's try: Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on win32 xx = b'x' repr(xx)

Re: Byte type?

2009-02-14 Thread Chris Rebert
On Sat, Feb 14, 2009 at 9:56 PM, Lie Ryan lie.1...@gmail.com wrote: On Sat, 14 Feb 2009 22:10:41 -0800, John Nagle wrote: xx = b'x' Isn't this creating a regular byte? Shouldn't creation of bytearray be: xx = bytearray(b'x') Indeed, and slicing that does give back a single byte (which