Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-03-03 Thread Nick Coghlan
Daniel Stutzbach wrote: > On 3/3/07, Bob Ippolito <[EMAIL PROTECTED]> wrote: >> When Erlang is printing the "repr" of a list or binary term to the >> shell it first checks to see if every item is printable ASCII integer. >> If so, then it prints as an ASCII string. Otherwise, it prints as a >> list

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-03-03 Thread Bob Ippolito
On 3/3/07, Daniel Stutzbach <[EMAIL PROTECTED]> wrote: > On 3/3/07, Bob Ippolito <[EMAIL PROTECTED]> wrote: > > When Erlang is printing the "repr" of a list or binary term to the > > shell it first checks to see if every item is printable ASCII integer. > > If so, then it prints as an ASCII string.

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-03-03 Thread Daniel Stutzbach
On 3/3/07, Bob Ippolito <[EMAIL PROTECTED]> wrote: > When Erlang is printing the "repr" of a list or binary term to the > shell it first checks to see if every item is printable ASCII integer. > If so, then it prints as an ASCII string. Otherwise, it prints as a > list of decimal integers. It doesn

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-03-03 Thread Bob Ippolito
On 3/3/07, Gareth McCaughan <[EMAIL PROTECTED]> wrote: > On Tuesday 27 February 2007 00:39, Greg Ewing wrote: > > > I can't help feeling the people arguing for b"..." as the > > repr format haven't really accepted the fact that text and > > binary data will be distinct things in py3k, and are think

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-03-03 Thread Gareth McCaughan
On Saturday 03 March 2007 16:02, I wrote: > Here's an ugly, impure, but possibly practical answer: > give each bytes object a single-bit flag meaning something > like "mostly textual"; ... > Obviously the flag wouldn't affect comparisons or hashing. Josiah Carlson mailed me to point out that, duh

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-03-03 Thread Gareth McCaughan
On Tuesday 27 February 2007 00:39, Greg Ewing wrote: > I can't help feeling the people arguing for b"..." as the > repr format haven't really accepted the fact that text and > binary data will be distinct things in py3k, and are thinking > of bytes as being a replacement for the old string type. B

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-26 Thread Greg Ewing
Josiah Carlson wrote: > Greg Ewing <[EMAIL PROTECTED]> wrote: > >>$[68656C6C6F] > > I think it's a bad idea to choose a representation with any format that > isn't able to do the eval(repr(obj)) loop. The intention was for that to be a valid literal syntax as well. > It may be the case > th

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-25 Thread Guido van Rossum
On 2/25/07, Greg Ewing <[EMAIL PROTECTED]> wrote: > But if they're displayed as characters by default, > what do I do to get them displayed as not-characters? Well anything that's not an ASCII printable is \x escaped anyway. If you want all hex, use the .hex() method described in the PEP. -- --G

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-25 Thread Josiah Carlson
Greg Ewing <[EMAIL PROTECTED]> wrote: > > Thomas Wouters wrote: > > > > I think you're confused. There isn't anything 'less generic' about the > > bytes literal. Both bytes([...]) and b"..." can express the full 256 > > value range. > > Yes, but it only makes sense to try to display it as > c

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-25 Thread Greg Ewing
Neil Schemenauer wrote: > Practicality beats purity here, I think. For example, if I'm > debugging a network protocol, I'd prefer > > b"EHLO ...\x0d\x0a" But what if I'm *not* debugging a network protocol, and my bytes objects all look like random gibberish when displayed as characters? To

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-25 Thread Greg Ewing
Thomas Wouters wrote: > > I think you're confused. There isn't anything 'less generic' about the > bytes literal. Both bytes([...]) and b"..." can express the full 256 > value range. Yes, but it only makes sense to try to display it as characters if it's meant to represent characters in the fir

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-25 Thread Greg Ewing
Jean-Paul Calderone wrote: > > Actually, writing that > > sort of literal makes me uncomfortable too, but I'm > > not sure what to do about that. > >[1, 2, 3] >(1, 2, 3) Not quite sure what your point is. My point is that I'm thoroughly conditioned to think of anything in quotes as immutab

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-25 Thread Neil Schemenauer
Greg Ewing <[EMAIL PROTECTED]> wrote: > That's my point -- you *don't* know how any given bytes > object was created, so there's no reason to display it > in anything other than the most generic way. Practicality beats purity here, I think. For example, if I'm debugging a network protocol, I'd pr

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-25 Thread Thomas Wouters
I think you're confused. There isn't anything 'less generic' about the bytes literal. Both bytes([...]) and b"..." can express the full 256 value range. On 2/25/07, Greg Ewing <[EMAIL PROTECTED]> wrote: Thomas Wouters wrote: > > I'm not sure what makes you say that. There isn't anyone actually

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-25 Thread Jean-Paul Calderone
On Mon, 26 Feb 2007 11:15:20 +1300, Greg Ewing <[EMAIL PROTECTED]> wrote: >Thomas Wouters wrote: >> >> I'm not sure what makes you say that. There isn't anyone actually using >> bytes() right now, so what makes you think how it's created? > >That's my point -- you *don't* know how any given bytes >

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-25 Thread Delaney, Timothy (Tim)
Greg Ewing wrote: > Another thing is that the idea of displaying a mutable > object in a way that closely resembles a non-mutable > literal makes me uncomfortable. Actually, writing that > sort of literal makes me uncomfortable too, but I'm > not sure what to do about that. We obviously need anot

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-25 Thread Greg Ewing
Thomas Wouters wrote: > > I'm not sure what makes you say that. There isn't anyone actually using > bytes() right now, so what makes you think how it's created? That's my point -- you *don't* know how any given bytes object was created, so there's no reason to display it in anything other than t

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-25 Thread Thomas Wouters
I'm not sure what makes you say that. There isn't anyone actually using bytes() right now, so what makes you think how it's created? Besides, lists can be created with list("foo") too, but they still repr() as ['f', 'o', 'o']. On 2/25/07, Greg Ewing <[EMAIL PROTECTED]> wrote: Georg Brandl wrote

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-25 Thread Greg Ewing
Georg Brandl wrote: > Seeing that, I made a patch that makes bytes_repr output a bytes literal, I'm not sure that's a good idea. Any given bytes object is as likely to have been constructed using bytes(...) as using b"...". There's no way of being sure whether displaying it as a string is appropr

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-24 Thread Guido van Rossum
Why not add the literal to 2.6 too? If that's deemed undesirable, make it bytes(), as long as that actually works when read back. --Guido On 2/24/07, Georg Brandl <[EMAIL PROTECTED]> wrote: > Guido van Rossum schrieb: > > Georg is channeling me well. Also, my thinking has evolved some after > >

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-24 Thread Georg Brandl
Guido van Rossum schrieb: > Georg is channeling me well. Also, my thinking has evolved some after > talking to various folks here at PyCon. > > Georg, please check it in! Feel free to update the PEP if you will. I will, if you answer me one question: in Python 2.6, should the repr() return "bytes

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-24 Thread Guido van Rossum
Georg is channeling me well. Also, my thinking has evolved some after talking to various folks here at PyCon. Georg, please check it in! Feel free to update the PEP if you will. --Guido On 2/24/07, Georg Brandl <[EMAIL PROTECTED]> wrote: > Giovanni Bajo schrieb: > > On 24/02/2007 11.20, Georg Br

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-24 Thread Georg Brandl
Giovanni Bajo schrieb: > On 24/02/2007 11.20, Georg Brandl wrote: > >> Thomas Wouters schrieb: >>> >>> That's exactly what it does in current p3yk: >>> >>> Python 3.0x (p3yk:53867M, Feb 23 2007, 20:06:03) >>> [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2 >>> Type "help", "copyright

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-24 Thread Giovanni Bajo
On 24/02/2007 11.20, Georg Brandl wrote: > Thomas Wouters schrieb: >> >> That's exactly what it does in current p3yk: >> >> Python 3.0x (p3yk:53867M, Feb 23 2007, 20:06:03) >> [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2 >> Type "help", "copyright", "credits" or "license" for more

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-24 Thread Georg Brandl
Thomas Wouters schrieb: That's exactly what it does in current p3yk: Python 3.0x (p3yk:53867M, Feb 23 2007, 20:06:03) [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> b"""abc ... def""" bytes([0x61, 0x62, 0

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-23 Thread Thomas Wouters
That's exactly what it does in current p3yk: Python 3.0x (p3yk:53867M, Feb 23 2007, 20:06:03) [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2 Type "help", "copyright", "credits" or "license" for more information. b"""abc ... def""" bytes([0x61, 0x62, 0x63, 0x0a, 0x64, 0x65, 0x66])

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-23 Thread Greg Ewing
Blake Winton wrote: > What would: > b"""abc > def""" > translate into, exactly? > [ 97, 98, 99, 10, 100, 101, 102 ]? > [ 97, 98, 99, 13, 10, 100, 101, 102 ]? > Platform-dependent? (E!) No, presumably it would always translate the newline into "\n" regardless of platform, as with current stri

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-23 Thread Georg Brandl
Jason Orendorff schrieb: > On 2/23/07, Thomas Wouters <[EMAIL PROTECTED]> wrote: >> On 2/21/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: >> > Patch anyone? >> >> See attachement. It's preliminary -- it just calls the global name 'bytes' >> currently (and not even using the 'right' AST concretion

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-23 Thread Jason Orendorff
On 2/23/07, Thomas Wouters <[EMAIL PROTECTED]> wrote: > On 2/21/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > Patch anyone? > > See attachement. It's preliminary -- it just calls the global name 'bytes' > currently (and not even using the 'right' AST concretion mechanism) which > means you ca

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-23 Thread Thomas Wouters
On 2/21/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: Patch anyone? See attachement. It's preliminary -- it just calls the global name 'bytes' currently (and not even using the 'right' AST concretion mechanism) which means you can override what the bytes literal creates by assigning to 'byt

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-23 Thread Brett Cannon
On 2/23/07, Jason Orendorff <[EMAIL PROTECTED]> wrote: > On 2/22/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > If someone would like to volunteer a small PEP on the b"..." literal I > > would appreciate it. > > I'll do this, unless someone tells me not to. A few questions. > Thomas Wouters

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-23 Thread Thomas Wouters
I'm not telling you not to do this, but I already wrote a preliminary patch (well, it's not actually *working* yet, but the hard part, the grammar changes, are working ;) Of course, it may be fun to compare implementations. On 2/23/07, Jason Orendorff <[EMAIL PROTECTED]> wrote: On 2/22/07, Guid

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-23 Thread Georg Brandl
Blake Winton schrieb: > Jason Orendorff wrote: >> On 2/22/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: >>> If someone would like to volunteer a small PEP on the b"..." literal I >>> would appreciate it. >> How do you feel about raw byte-strings (br'a\b\c') > > Not that my opinion particularly m

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-23 Thread Blake Winton
Jason Orendorff wrote: > On 2/22/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: >> If someone would like to volunteer a small PEP on the b"..." literal I >> would appreciate it. > How do you feel about raw byte-strings (br'a\b\c') Not that my opinion particularly matters, but I would say "sure" t

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-23 Thread Jason Orendorff
On 2/22/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > If someone would like to volunteer a small PEP on the b"..." literal I > would appreciate it. I'll do this, unless someone tells me not to. A few questions. The grammar for string literals is already changing in py3k (removing the toleran

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-22 Thread Terry Reedy
"Guido van Rossum" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | FWIW, I've updated PEP 358 (the bytes object) to more closely reflect | my plans for it, showing the preservation of most string methods. It | should be updated on the website in a few minutes. | | If someone would l

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-22 Thread Guido van Rossum
FWIW, I've updated PEP 358 (the bytes object) to more closely reflect my plans for it, showing the preservation of most string methods. It should be updated on the website in a few minutes. If someone would like to volunteer a small PEP on the b"..." literal I would appreciate it. The main concern

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-21 Thread Greg Ewing
Jim Jewett wrote: > A literal form does clear it up, though I'm not sure "b" is the right > prefix. (I keep wanting to read "binary" or "boolean", rather than > "ASCII") It means "bytes". The ASCII part is that you've written characters in quotes after it. -- Greg __

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-21 Thread Guido van Rossum
Right. The b"..." literal doesn't have this problem because problems always show up in the bytecode compilation stage; that's the beauty of b"...". Patch anyone? On 2/21/07, Josiah Carlson <[EMAIL PROTECTED]> wrote: > > "Jim Jewett" <[EMAIL PROTECTED]> wrote: > > > > On 2/21/07, Guido van Rossum <

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-21 Thread Josiah Carlson
"Jim Jewett" <[EMAIL PROTECTED]> wrote: > > On 2/21/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > If the spelling of a bytes string with an ASCII character value is all > > you are complaining about, you should have said so right away. > > That is my main objection. > > A literal form doe

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-21 Thread Guido van Rossum
Sorry, that was an unfortunate typo. bytes are Mutable. (It's the same as in Java, really.) On 2/21/07, Jim Jewett <[EMAIL PROTECTED]> wrote: > Are bytes supposed to be mutable? > > Josiah: > > even be changed to *take* a bytes object as the destination buffer > > Guido: > > This already works --

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-21 Thread Jim Jewett
Are bytes supposed to be mutable? Josiah: > even be changed to *take* a bytes object as the destination buffer Guido: > This already works -- bytes support the buffer API. but later: > I think you misunderstood the plans for bytes. The plan is for the > performance with bytes to scream, in part

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-21 Thread Jim Jewett
On 2/21/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > If the spelling of a bytes string with an ASCII character value is all > you are complaining about, you should have said so right away. That is my main objection. A literal form does clear it up, though I'm not sure "b" is the right prefix

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-21 Thread Josiah Carlson
"Guido van Rossum" <[EMAIL PROTECTED]> wrote: > On 2/20/07, Josiah Carlson <[EMAIL PROTECTED]> wrote: > > Better than returning unicode, but not as good as returning "binary". > > It never was the plan to have this return unicode BTW. > > What's the difference between "binary" and "bytes"? To me

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-20 Thread Guido van Rossum
On 2/20/07, Josiah Carlson <[EMAIL PROTECTED]> wrote: > > "Guido van Rossum" <[EMAIL PROTECTED]> wrote: > > [Note: changed subject] > > On 2/20/07, Josiah Carlson <[EMAIL PROTECTED]> wrote: > > > I'm not so sure. The return type on socket.recv and os.read could be > > > changed to bytes (seemingly

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-20 Thread Josiah Carlson
"Guido van Rossum" <[EMAIL PROTECTED]> wrote: > [Note: changed subject] > On 2/20/07, Josiah Carlson <[EMAIL PROTECTED]> wrote: > > I'm not so sure. The return type on socket.recv and os.read could be > > changed to bytes (seemingly without much difficulty), > > Yes, that's the plan anyway. Bet

Re: [Python-3000] Thoughts on new I/O library and bytecode

2007-02-20 Thread Guido van Rossum
[Note: changed subject] On 2/20/07, Josiah Carlson <[EMAIL PROTECTED]> wrote: > > "Guido van Rossum" <[EMAIL PROTECTED]> wrote: > > On 2/20/07, Paul Moore <[EMAIL PROTECTED]> wrote: > > > (I have similar concerns over the "new IO" proposals I've > > > seen, but there's nothing concrete there yet,