Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-15 Thread Stephen J. Turnbull
Tres Seaver writes: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 01/15/2014 12:57 AM, Stephen J. Turnbull wrote: asciistr *canonizes* something as an ASCII string, and therefore compatible with both bytes and str. It can't *create* such a thing ex nihilo. How many

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-14 Thread Greg Ewing
Guido van Rossum wrote: I've now looked at asciistr. (Thanks Glenn and Ethan for the link.) Now that I (hopefully) understand it, I'm worried that a text processing algorithm that uses asciistr might under hard-to-predict circumstances (such as when the arguments contain nothing of interest to

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-14 Thread Stephen J. Turnbull
Nick Coghlan writes: Give up makes it sound like I got tired of arguing without being convinced rather than admitting I was just plain wrong. I thought it was something in between (you explicitly said lenient PEP 460 doesn't hurt you, but my understanding was you still believe that there's a

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-14 Thread Nick Coghlan
On 14 Jan 2014 19:11, Stephen J. Turnbull step...@xemacs.org wrote: Nick Coghlan writes: Give up makes it sound like I got tired of arguing without being convinced rather than admitting I was just plain wrong. I thought it was something in between (you explicitly said lenient PEP 460

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-14 Thread Guido van Rossum
On Tue, Jan 14, 2014 at 12:20 AM, Greg Ewing greg.ew...@canterbury.ac.nz wrote: Guido van Rossum wrote: I've now looked at asciistr. (Thanks Glenn and Ethan for the link.) Now that I (hopefully) understand it, I'm worried that a text processing algorithm that uses asciistr might under

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-14 Thread Guido van Rossum
On Tue, Jan 14, 2014 at 7:59 AM, Guido van Rossum gu...@python.org wrote: Here's an example of what I mean: I sent that off without proofreading, and I also got one detail about asciistr() wrong. Here are some corrections. def spam(a): r = asciistr('(') if a: r += a.strip() r +=

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-14 Thread Guido van Rossum
[Other readers: asciistr is at https://github.com/jeamland/asciicompat] On Mon, Jan 13, 2014 at 11:44 PM, Nick Coghlan ncogh...@gmail.com wrote: Right, asciistr is designed for a specific kind of hybrid API where you want to accept binary input (and produce binary output) *and* you want to

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-14 Thread Nick Coghlan
On 15 Jan 2014 04:16, Guido van Rossum gu...@python.org wrote: [Other readers: asciistr is at https://github.com/jeamland/asciicompat] On Mon, Jan 13, 2014 at 11:44 PM, Nick Coghlan ncogh...@gmail.com wrote: Right, asciistr is designed for a specific kind of hybrid API where you want to

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-14 Thread Greg Ewing
Guido van Rossum wrote: def spam(a): r = asciistr('(') if a: r += a.strip() r += asciistr(')') return r The general fix would be to add else: r += a[:0] The awkwardness might be reducable if asciistr let you write something like r = asciistr('(', a) meaning give me

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-14 Thread Nick Coghlan
On 15 Jan 2014 08:00, Greg Ewing greg.ew...@canterbury.ac.nz wrote: Guido van Rossum wrote: def spam(a): r = asciistr('(') if a: r += a.strip() r += asciistr(')') return r The general fix would be to add else: r += a[:0] The awkwardness might be reducable if

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-14 Thread Greg Ewing
Guido van Rossum wrote: Actually, Nick explained that asciistr() + asciistr() returns str, That part seems wrong to me, because it means that you can't write polymorphic byte/string functions that are composable. I would be -1 on that, and prefer that asciistr + asciistr -- asciistr. -- Greg

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-14 Thread Nick Coghlan
On 15 Jan 2014 08:14, Greg Ewing greg.ew...@canterbury.ac.nz wrote: Guido van Rossum wrote: Actually, Nick explained that asciistr() + asciistr() returns str, That part seems wrong to me, because it means that you can't write polymorphic byte/string functions that are composable. I

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-14 Thread Guido van Rossum
On Tue, Jan 14, 2014 at 1:37 PM, Nick Coghlan ncogh...@gmail.com wrote: Yep - that's why I consider asciistr to be firmly in the power tool category. If you know what you're doing, it should let you write hybrid API code that is just as concise as Python 2, but it's also far more error prone

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-14 Thread Greg Ewing
Nick Coghlan wrote: On 15 Jan 2014 08:00, Greg Ewing greg.ew...@canterbury.ac.nz mailto:greg.ew...@canterbury.ac.nz wrote: If so, would it help if asciistr were a built-in type, so that other things could be made aware of it? That way lies the Python 2 text model, and we're not going

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-14 Thread Steven D'Aprano
On Tue, Jan 14, 2014 at 10:16:17AM -0800, Guido van Rossum wrote: Hm. It is beginning to sound more and more flawed. I also worry that it will bring back the nightmare of data-dependent UnicodeError back. E.g. this (from tests/basic.py): def

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-14 Thread Steven D'Aprano
On Wed, Jan 15, 2014 at 01:03:13PM +1300, Greg Ewing wrote: Nick Coghlan wrote: That way lies the Python 2 text model, and we're not going there. It's probably best to think of asciistr as a way of demonstrating a rhetorical point about the superiority of the Python 3 text model Hmmm...

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-14 Thread Greg Ewing
Steven D'Aprano wrote: I don't think mixing bytes and strings makes good semantic sense. It's not about mixing bytes and text -- it's about writing polymorphic code that will work on either bytes *or* text. Not both at the same time. If we had quantum computers, this would be easy to solve:

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-14 Thread Stephen J. Turnbull
Steven D'Aprano writes: I thought I understand the purpose of asciistr was exactly that, to produce something that was compatible with both bytes and strings. asciistr *canonizes* something as an ASCII string, and therefore compatible with both bytes and str. It can't *create* such a thing

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-14 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 01/15/2014 12:57 AM, Stephen J. Turnbull wrote: asciistr *canonizes* something as an ASCII string, and therefore compatible with both bytes and str. It can't *create* such a thing ex nihilo. How many miracles must be attested? Tres. - --

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-13 Thread Stephen J. Turnbull
Ethan Furman writes: The part that you don't seem to acknowledge (sorry if I missed it) is that there are str-like methods already on bytes. I haven't expressed myself well, but I don't much care about that. It's what Knuth would classify as a seminumerical method. What I do care about is

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-13 Thread Stephen J. Turnbull
Glenn Linderman writes: On 1/12/2014 4:08 PM, Stephen J. Turnbull wrote: Glenn Linderman writes: the proposals to embed binary in Unicode by abusing Latin-1 encoding. Those aren't proposals, they are currently feasible techniques in Python 3 for *some* use cases. The question is why

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-13 Thread Ethan Furman
On 01/13/2014 02:48 AM, Stephen J. Turnbull wrote: Ethan Furman writes: The part that you don't seem to acknowledge (sorry if I missed it) is that there are str-like methods already on bytes. I haven't expressed myself well, but I don't much care about that. You don't care that there are

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-13 Thread Glenn Linderman
On 1/13/2014 6:43 AM, Stephen J. Turnbull wrote: Glenn Linderman writes: On 1/12/2014 4:08 PM, Stephen J. Turnbull wrote: Glenn Linderman writes: the proposals to embed binary in Unicode by abusing Latin-1 encoding. Those aren't proposals, they are currently feasible

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-13 Thread Greg Ewing
Stephen J. Turnbull wrote: PBP doesn't think it's a great idea to pass around bytes that are implicitly some other type, but didn't mind it (or got used to it) in Python 2, and so they're not looking at that as a problem that Python 3 can solve. They're looking at Python 3 as the problem that

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-13 Thread Emile van Sebille
On 1/13/2014 4:06 PM, Greg Ewing wrote: snip of text methods -- together with a text-like literal syntax and default repr(), even though at least half the time they're completely inappropriate! Better said as 'half the time they're coincidentally helpful!' My $.01 :) Emile

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-13 Thread Stephen J. Turnbull
Glenn Linderman writes: On 1/13/2014 6:43 AM, Stephen J. Turnbull wrote: Glenn Linderman writes: smuggled binary (great term borrowed from a different subthread) muddies the waters of what you are dealing with. Not really. The mud is one or more of the serious deficiencies. It can be

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-13 Thread Guido van Rossum
Sorry to butt in, but can you post a link to the asciistr code? Google has too many hits for other things to be useful to find it, it seems. -- --Guido van Rossum (python.org/~guido) ___ Python-Dev mailing list Python-Dev@python.org

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-13 Thread Stephen J. Turnbull
Greg Ewing writes: I don't think of my viewpoint as being PBP. That term assumes there is purity there to be beaten. To my mind, any notion of purity with respect to bytes objects went out the window as soon as it was given a pile of text methods -- together with a text-like literal

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-13 Thread Glenn Linderman
On 1/13/2014 9:06 PM, Guido van Rossum wrote: Sorry to butt in, but can you post a link to the asciistr code? Google has too many hits for other things to be useful to find it, it seems. https://github.com/jeamland/asciicompat ___ Python-Dev mailing

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-13 Thread Ethan Furman
On 01/13/2014 09:06 PM, Guido van Rossum wrote: Sorry to butt in, but can you post a link to the asciistr code? Google has too many hits for other things to be useful to find it, it seems. https://github.com/jeamland/asciicompat -- ~Ethan~ ___

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-13 Thread Nick Coghlan
On 14 January 2014 15:15, Stephen J. Turnbull step...@xemacs.org wrote: The purity position is probably going to lose in the end, since Guido is clearly in the PBP camp at this point, and that's a strong indicator (especially since Nick has given up on convincing python-dev). But that does

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-13 Thread Ethan Furman
On 01/13/2014 09:06 PM, Guido van Rossum wrote: In contrast, here's the tests I drew up for what I thought bytes should do for us (no code, just tests): https://bitbucket.org/stoneleaf/bytestring -- ~Ethan~ ___ Python-Dev mailing list

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-13 Thread Ethan Furman
On 01/13/2014 09:12 PM, Ethan Furman wrote: On 01/13/2014 09:06 PM, Guido van Rossum wrote: In contrast, here's the tests I drew up for what I thought bytes should do for us (no code, just tests): https://bitbucket.org/stoneleaf/bytestring Ugh. Ignore for now, I need to update them to

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-13 Thread Nick Coghlan
On 14 January 2014 16:04, Guido van Rossum gu...@python.org wrote: On Mon, Jan 13, 2014 at 9:34 PM, Nick Coghlan ncogh...@gmail.com wrote: I've now looked at asciistr. (Thanks Glenn and Ethan for the link.) Now that I (hopefully) understand it, I'm worried that a text processing algorithm

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Paul Moore
On 12 January 2014 01:01, Victor Stinner victor.stin...@gmail.com wrote: Supporting formating integers would allow to write bContent-Length: %s\r\n % 123, which would work on Python 2 and Python 3. I'm surprised that no-one is mentioning bContent-Length: %s\r\n % str(123) which works on Python

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Georg Brandl
Am 12.01.2014 09:57, schrieb Paul Moore: On 12 January 2014 01:01, Victor Stinner victor.stin...@gmail.com wrote: Supporting formating integers would allow to write bContent-Length: %s\r\n % 123, which would work on Python 2 and Python 3. I'm surprised that no-one is mentioning

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Paul Moore
On 12 January 2014 09:23, Georg Brandl g.bra...@gmx.net wrote: On 12 January 2014 01:01, Victor Stinner victor.stin...@gmail.com wrote: Supporting formating integers would allow to write bContent-Length: %s\r\n % 123, which would work on Python 2 and Python 3. I'm surprised that no-one is

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Nick Coghlan
On 12 Jan 2014 22:10, Paul Moore p.f.mo...@gmail.com wrote: On 12 January 2014 09:23, Georg Brandl g.bra...@gmx.net wrote: On 12 January 2014 01:01, Victor Stinner victor.stin...@gmail.com wrote: Supporting formating integers would allow to write bContent-Length: %s\r\n % 123, which would

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Kristján Valur Jónsson
From: Python-Dev [python-dev-bounces+kristjan=ccpgames@python.org] on behalf of Georg Brandl [g.bra...@gmx.net] Sent: Sunday, January 12, 2014 09:23 To: python-dev@python.org Subject: Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake Am 12.01.2014 09:57, schrieb Paul Moore

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Lennart Regebro
On Sat, Jan 11, 2014 at 8:40 PM, Kristján Valur Jónsson krist...@ccpgames.com wrote: Hi there. How about a compromise? Personally, I think adding the full complement of integer/float formatting to bytes is a bit over the top. How about just supporting two format specifiers? %b : interpolate

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Nick Coghlan
of Georg Brandl [g.bra...@gmx.net] Sent: Sunday, January 12, 2014 09:23 To: python-dev@python.org Subject: Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake Am 12.01.2014 09:57, schrieb Paul Moore: On 12 January 2014 01:01, Victor Stinner victor.stin...@gmail.com wrote: Supporting

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Ethan Furman
On 01/12/2014 08:09 AM, Nick Coghlan wrote: On 13 Jan 2014 01:22, Kristján Valur Jónsson wrote: Imho, this is not equivalent to re-introducing automatic type conversion between binary/unicode, it is adding a specific convenience function for explicitly asking for ASCII encoding. It is not

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Kristján Valur Jónsson
16:09 To: Kristján Valur Jónsson Cc: python-dev@python.org; Georg Brandl Subject: Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake It is not explicit, it is implicit - whether or not the resulting string assumes ASCII compatibility or not depends on whether you pass a binary value

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Ethan Furman
On 01/12/2014 08:21 AM, Ethan Furman wrote: On 01/12/2014 08:09 AM, Nick Coghlan wrote: On 13 Jan 2014 01:22, Kristján Valur Jónsson wrote: Imho, this is not equivalent to re-introducing automatic type conversion between binary/unicode, it is adding a specific convenience function for

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Paul Moore
On 12 January 2014 16:52, Kristján Valur Jónsson krist...@ccpgames.com wrote: I mean, basically what I am suggesting is that in addition to %b with def helper(o): return str(o).encode('ascii', 'strict') b'foo%bbar'%(helper(myobj), ) you have b'foo%sbar'%(myobj, ) But that's not what

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Mark Shannon
; Georg Brandl *Subject:* Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake It is not explicit, it is implicit - whether or not the resulting string assumes ASCII compatibility or not depends on whether you pass a binary value (no assumption) or a string value (assumes ASCII compatibility

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Mark Lawrence
On 12/01/2014 17:06, Mark Shannon wrote: On 12/01/14 16:52, Kristján Valur Jónsson wrote: Now you're just splitting hairs, Nick. An explicit operator, %s, _defined_ to be encode a string object using strict ascii, I don't like this because '%s' reads to me as insert *string* here. I think

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Paul Moore
On 12 January 2014 17:03, Ethan Furman et...@stoneleaf.us wrote: We know full well the difference between unicode and bytes, and we know full well that numbers and much of the text we need has an ASCII (bytes!) representation. When we do a b'Content Length: %d' % len(binary_data) we are

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Ethan Furman
On 01/12/2014 09:26 AM, Paul Moore wrote: On 12 January 2014 17:03, Ethan Furman et...@stoneleaf.us wrote: We know full well the difference between unicode and bytes, and we know full well that numbers and much of the text we need has an ASCII (bytes!) representation. When we do a b'Content

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Paul Moore
On 12 January 2014 18:26, Ethan Furman et...@stoneleaf.us wrote: True enough! ;) It's unacceptable in the sense that the bytes type is /almost/ there, it's /almost/ what is needed to handle the boundary conditions. We have a __bytes__ method (how is it supposed to be used?) that could be

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread INADA Naoki
I want to add one more PoV: small performance regression, especially on Python 2. Because programs that needs byte formatting may be low level and used heavily from application. Many programs uses one source approach to support Python 3. And supporting Python 3 should not means large performance

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Ethan Furman
On 01/11/2014 07:09 PM, Nick Coghlan wrote: Folks that want implicit serialisation (and I agree it has its uses) should go help Benno get asciistr up to speed. asciistr is not what I'm looking for in the way of a boundary type. I have created a 'bytestring'[1] repository which has the tests

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Emile van Sebille
On 01/12/2014 09:26 AM, Paul Moore wrote: Can you give an example of code that is *nearly* acceptable to you, which works in Python 2 and 3 today, and explain what improvements you would like to see to it in order to use it instead of waiting for a core change? I'm not a developer, but I'm

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Ethan Furman
On 01/12/2014 11:00 AM, Paul Moore wrote: And yet I still don't follow what you *want*. Unless it's that b'%d' % (12,) must work and give b'12', and nothing else is acceptable. Nothing else is ideal. I'll go that route if I have to. I understand that in the real world you go with what

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Paul Moore
On 12 January 2014 19:30, Emile van Sebille em...@fenx.com wrote: len(open('chars','wb').write(.join(map (chr,range(256.read()) Python 2: len(open('chars','wb').write(.join(map (chr,range(256.read()) Traceback (most recent call last): File stdin, line 1, in module AttributeError:

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Emile van Sebille
On 01/12/2014 11:30 AM, Emile van Sebille wrote: On 01/12/2014 09:26 AM, Paul Moore wrote: Can you give an example of code that is *nearly* acceptable to you, which works in Python 2 and 3 today, and explain what improvements you would like to see to it in order to use it instead of waiting for

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Stephen J. Turnbull
Georg Brandl writes: if it weren't for your stupid maximalist opposition). Can you please stop throwing personal insults around? You don't have to resort to that level. Ethan's posts (as an example of one general trend in this thread) are pretty frustrating, you have to admit. MAL

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Georg Brandl
Am 12.01.2014 20:30, schrieb Emile van Sebille: On 01/12/2014 09:26 AM, Paul Moore wrote: Can you give an example of code that is *nearly* acceptable to you, which works in Python 2 and 3 today, and explain what improvements you would like to see to it in order to use it instead of waiting for

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Greg Ewing
Paul Moore wrote: I could easily argue at this point that this is the type of bug that having %-formatting operations on bytes would encourage - %s means format a string (from years of C and Python (text) experience) so I automatically supply a string argument when using %s in a bytes formatting

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Mark Lawrence
On 12/01/2014 21:06, Greg Ewing wrote: Paul Moore wrote: I could easily argue at this point that this is the type of bug that having %-formatting operations on bytes would encourage - %s means format a string (from years of C and Python (text) experience) so I automatically supply a string

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Greg Ewing
Nick Coghlan wrote: On 13 Jan 2014 01:22, Kristján Valur Jónsson krist...@ccpgames.com mailto:krist...@ccpgames.com wrote: Well, my suggestion would that we _should_ make it work, by having the %s format specifyer on bytes objects mean: str(arg).encode('ascii', 'strict') It is not

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Ethan Furman
On 01/12/2014 12:02 PM, Stephen J. Turnbull wrote: Georg Brandl writes: Antoine writes: . . . if it weren't for your stupid maximalist opposition. . . Can you please stop throwing personal insults around? You don't have to resort to that level. Ethan's posts (as an example of one general

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Kristján Valur Jónsson
, January 12, 2014 17:04 To: Kristján Valur Jónsson Cc: Nick Coghlan; Georg Brandl; python-dev@python.org Subject: Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake On 12 January 2014 16:52, Kristján Valur Jónsson krist...@ccpgames.com wrote: But that's not what the current PEP says. It uses %s

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Kristján Valur Jónsson
+1, even better. From: Python-Dev [python-dev-bounces+kristjan=ccpgames@python.org] on behalf of Mark Shannon [m...@hotpy.org] Sent: Sunday, January 12, 2014 17:06 To: python-dev@python.org Subject: Re: [Python-Dev] PEP 460: allowing %d and %f

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Ethan Furman
On 01/12/2014 01:06 PM, Greg Ewing wrote: Paul Moore wrote: I could easily argue at this point that this is the type of bug that having %-formatting operations on bytes would encourage - %s means format a string (from years of C and Python (text) experience) so I automatically supply a string

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Ethan Furman
On 01/12/2014 01:37 PM, Kristján Valur Jónsson wrote: Right. I'm saying, let's support two interpolators only: %b interpolates a bytes object (or one supporting the charbuffer interface) into a bytes object. %s interpolates a str object by first converting to a bytes object using strict ascii

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Glenn Linderman
On 1/12/2014 11:14 AM, Ethan Furman wrote: And a core principle of the bytes/text separation in Python 3 is that encoding should never happen implicitly. That could be. And yet the bytes type already has several concessions to ASCII encoding. %d % 26 = an explicit request to convert binary

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Greg Ewing
Paul Moore wrote: On 12 January 2014 18:26, Ethan Furman et...@stoneleaf.us wrote: I'm arguing from three PoVs: 1) 2 3 compatible code base 2) having the bytes type /be/ the boundary type 3) readable code The only one of these that I can see being in any way an argument against def

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Greg Ewing
Ethan Furman wrote: Your asciistr, which sometimes returns bytes and sometimes returns text, is absolutely *not* what we want. The kind of third-party thing that *might* fill the bill would be a *function*: bytesformat(bContent-Length: %d, length) that implements all the %-specifiers

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Greg Ewing
Mark Lawrence wrote: I entirely agree. This would also parallel the conversion flags given here http://docs.python.org/3/library/string.html#format-string-syntax, I quote Three conversion flags are currently supported: '!s' which calls str() on the value, '!r' which calls repr() and '!a'

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Paul Moore
On 12 January 2014 22:10, Greg Ewing greg.ew...@canterbury.ac.nz wrote: I think the readability argument becomes a bit sharper when you consider more complex examples, e.g. if I have a tuple of 3 floats that I want to put into a PDF file, then b%f %f %f % my_floats is considerably

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Mark Lawrence
On 12/01/2014 17:03, Ethan Furman wrote: On 01/12/2014 08:21 AM, Ethan Furman wrote: On 01/12/2014 08:09 AM, Nick Coghlan wrote: On 13 Jan 2014 01:22, Kristján Valur Jónsson wrote: Imho, this is not equivalent to re-introducing automatic type conversion between binary/unicode, it is adding a

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Antoine Pitrou
Hi Ethan, On Sun, 12 Jan 2014 13:28:15 -0800 Ethan Furman et...@stoneleaf.us wrote: On 01/12/2014 12:02 PM, Stephen J. Turnbull wrote: Georg Brandl writes: Antoine writes: . . . if it weren't for your stupid maximalist opposition. . . Can you please stop throwing personal insults

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Stephen J. Turnbull
Ethan Furman writes: Nothing else is ideal. I'll go that route if I have to. I understand that in the real world you go with what works, but in the development stage you fight for the ideal. :) You're going to lose, because Python 3 chose a different ideal that conflicts with yours.

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Glenn Linderman
On 1/12/2014 2:57 PM, Stephen J. Turnbull wrote: But bytes already acknowledges an ASCII bias. True, but that bias is implemented without use of encoding or decoding. b'%d' % (123,) - b'123' does require encoding, at the very least in the sense of type change and serialization. b'%d' all

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Ethan Furman
On 01/12/2014 02:57 PM, Stephen J. Turnbull wrote: Ethan Furman writes: Nothing else is ideal. I'll go that route if I have to. I understand that in the real world you go with what works, but in the development stage you fight for the ideal. :) You're going to lose, because Python 3 chose

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Ethan Furman
On 01/12/2014 02:52 PM, Antoine Pitrou wrote: You are right, it is not ok. The wording wasn't constructive or controlled at all. I'd like to apologize for that. Thank you. Apology accepted. At the same point, I was expressing a fair amount of frustration. I think the last discussion

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Stephen J. Turnbull
Glenn Linderman writes: the proposals to embed binary in Unicode by abusing Latin-1 encoding. Those aren't proposals, they are currently feasible techniques in Python 3 for *some* use cases. The question is why infecting Python 3 with the byte/character confoundance virus is preferable to

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Stephen J. Turnbull
Ethan Furman writes: 1) Are you saying it's okay to be insulting when frustrated? I also find this mega-thread frustrating, but I'm trying very hard not to be insulting. OK, no. Understandable, yes. 2) If you are going to use my name, please be certain of the facts [1].

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Scott Dial
On 2014-01-11 22:09, Nick Coghlan wrote: For Python 2 folks trying to grok where the bright line is in terms of the Python 3 text model: if your proposal includes *any* kind of implicit serialisation of non binary data to binary, it is going to be rejected as an addition to the core bytes

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Guido van Rossum
Those still arguing on this thread might want to look at the thread PEP 460 reboot. -- --Guido van Rossum (python.org/~guido) ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe:

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Stephen J. Turnbull
Ethan Furman writes: On 01/12/2014 02:57 PM, Stephen J. Turnbull wrote: No, Nick's point is that there's no encoding needed there are all, just a bunch of methods that handle numbers in the range 0-255. You can rationalize the particular choice of numbers by referring to the ASCII

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Ethan Furman
On 01/12/2014 07:02 PM, Stephen J. Turnbull wrote: [snip most of very eloquent reply] Thank you, Stephen, for remaining calm despite my somewhat heated response. A few comments in-line. I now better understand your viewpoint about text always being unicode strings; I just happen to disagree.

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Ethan Furman
On 01/12/2014 08:27 PM, Stephen J. Turnbull wrote: Ethan Furman writes: On 01/12/2014 02:57 PM, Stephen J. Turnbull wrote: I didn't trim enough to make my point clear. My apologies. But knowledge of ASCII isn't necessary to specify these methods; they can be defined in an

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Ethan Furman
On 01/12/2014 02:32 PM, Mark Lawrence wrote: I've just tried asciistr using your test code (having corrected the typo, it's assertIsInstance, not assertIsinstance :) and it looks like a very good starting point. Have you, or anyone else for that matter, actually tried asciistr out? Ah,

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Glenn Linderman
On 1/12/2014 8:00 PM, Ethan Furman wrote: Okay, I've thought somewhat. Under the definition above would it be fair to say that Db3Table (a class in my dbf module) is a boundary type? It sits between the actual file and the program, and transforms bytes into actual Python types. Yes.

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-12 Thread Glenn Linderman
On 1/12/2014 4:08 PM, Stephen J. Turnbull wrote: Glenn Linderman writes: the proposals to embed binary in Unicode by abusing Latin-1 encoding. Those aren't proposals, they are currently feasible techniques in Python 3 for *some* use cases. The question is why infecting Python 3 with the

[Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-11 Thread Victor Stinner
Hi, I'm in favor of adding support of formatting integer and floatting point numbers in the PEP 460: %d, %u, %o, %x, %f with padding and precision (%10d, %010d, %1.5f) and sign (%-i, %+i) but without alternate format ({:#x}). %s would also accept int and float for convenience. int and float

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-11 Thread Antoine Pitrou
On Sat, 11 Jan 2014 18:41:49 +0100 Victor Stinner victor.stin...@gmail.com wrote: If you agree, I will modify the PEP. If Antoine disagree, I will fork the PEP 460 ;-) Please fork it. b'x=%s' % 10 is well defined, it's pure bytes. It is well-defined? Then please explain me what the general

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-11 Thread Ethan Furman
On 01/11/2014 10:32 AM, Antoine Pitrou wrote: On Sat, 11 Jan 2014 18:41:49 +0100 Victor Stinner victor.stin...@gmail.com wrote: If you agree, I will modify the PEP. If Antoine disagree, I will fork the PEP 460 ;-) Please fork it. You've already stated you don't care that much and are

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-11 Thread Antoine Pitrou
On Sat, 11 Jan 2014 10:38:01 -0800 Ethan Furman et...@stoneleaf.us wrote: On 01/11/2014 10:32 AM, Antoine Pitrou wrote: On Sat, 11 Jan 2014 18:41:49 +0100 Victor Stinner victor.stin...@gmail.com wrote: If you agree, I will modify the PEP. If Antoine disagree, I will fork the PEP 460 ;-)

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-11 Thread Kristján Valur Jónsson
Message- From: Python-Dev [mailto:python-dev-bounces+kristjan=ccpgames@python.org] On Behalf Of Victor Stinner Sent: 11. janúar 2014 17:42 To: Python Dev Subject: [Python-Dev] PEP 460: allowing %d and %f and mojibake Hi, I'm in favor of adding support of formatting integer and floatting

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-11 Thread Barry Warsaw
On Jan 11, 2014, at 10:38 AM, Ethan Furman wrote: You've already stated you don't care that much and are willing to let the PEP as-is be rejected. Why not remove your name and let Victor have it back? Is he not the original author? (If this is protocol just say so -- remember I'm still new to

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-11 Thread Ethan Furman
On 01/11/2014 11:22 AM, Antoine Pitrou wrote: On Sat, 11 Jan 2014 10:38:01 -0800 Ethan Furman et...@stoneleaf.us wrote: On 01/11/2014 10:32 AM, Antoine Pitrou wrote: On Sat, 11 Jan 2014 18:41:49 +0100 Victor Stinner victor.stin...@gmail.com wrote: If you agree, I will modify the PEP. If

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-11 Thread Georg Brandl
Am 11.01.2014 20:22, schrieb Antoine Pitrou: On Sat, 11 Jan 2014 10:38:01 -0800 Ethan Furman et...@stoneleaf.us wrote: On 01/11/2014 10:32 AM, Antoine Pitrou wrote: On Sat, 11 Jan 2014 18:41:49 +0100 Victor Stinner victor.stin...@gmail.com wrote: If you agree, I will modify the PEP. If

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-11 Thread Serhiy Storchaka
11.01.14 21:40, Kristján Valur Jónsson написав(ла): How about a compromise? Personally, I think adding the full complement of integer/float formatting to bytes is a bit over the top. How about just supporting two format specifiers? %b : interpolate a bytes object. If it doesn't have the buffer

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-11 Thread Georg Brandl
Am 11.01.2014 22:01, schrieb Serhiy Storchaka: 11.01.14 21:40, Kristján Valur Jónsson написав(ла): How about a compromise? Personally, I think adding the full complement of integer/float formatting to bytes is a bit over the top. How about just supporting two format specifiers? %b :

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-11 Thread Ethan Furman
On 01/11/2014 10:32 AM, Antoine Pitrou wrote: On Sat, 11 Jan 2014 18:41:49 +0100 Victor Stinner victor.stin...@gmail.com wrote: b'x=%s' % 10 is well defined, it's pure bytes. It is well-defined? Then please explain me what the general case of b'%s' % x is supposed to call: This is the

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-11 Thread Victor Stinner
2014/1/11 Ethan Furman et...@stoneleaf.us: b'x=%s' % 10 is well defined, it's pure bytes. It is well-defined? Then please explain me what the general case of b'%s' % x is supposed to call: This is the key question, isn't it? Python 2 and Python 3 are very different here. In Python 2,

Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

2014-01-11 Thread Glenn Linderman
On 1/11/2014 1:50 PM, Ethan Furman wrote: Perhaps that's the problem. According to the docs: object.__bytes__(self) Called by bytes() to compute a byte-string representation of an object. This should return a bytes

  1   2   >