Re: [Python-Dev] Python3 "complexity" (was RFC: PEP 460: Add bytes...)

2014-01-08 Thread Nick Coghlan
On 9 January 2014 15:22, Greg Ewing wrote: > Kristján Valur Jónsson wrote: >> >> all you want is to open that .txt >> file on the drive and extract some phone numbers and merge in some email >> addresses. What encoding does the file have? Do I care? Must I care? > > > To some extent, yes. If the e

Re: [Python-Dev] Python3 "complexity"

2014-01-08 Thread Ben Finney
Nick Coghlan writes: > On 9 January 2014 10:07, Ben Finney wrote: > > Kristján Valur Jónsson writes: > > > >> Believe it or not, sometimes you really don't care about encodings. > >> Sometimes you just want to parse text files. > > > > Files don't contain text, they contain bytes. Bytes only be

Re: [Python-Dev] Python3 "complexity"

2014-01-08 Thread Nick Coghlan
On 9 January 2014 10:07, Ben Finney wrote: > Kristján Valur Jónsson writes: > >> Believe it or not, sometimes you really don't care about encodings. >> Sometimes you just want to parse text files. > > Files don't contain text, they contain bytes. Bytes only become text > when filtered through the

Re: [Python-Dev] Python3 "complexity"

2014-01-08 Thread Nick Coghlan
On 9 January 2014 10:22, Kristján Valur Jónsson wrote: > Still playing the devil's advocate: > I didn't used to must. Why must I must now? Did the universe just shift > when I fired up python3? > Things were demonstatably working just fine before without doing so. They were working fine for ex

Re: [Python-Dev] Python3 "complexity"

2014-01-08 Thread Mark Lawrence
On 09/01/2014 06:50, Lennart Regebro wrote: On Thu, Jan 9, 2014 at 1:07 AM, Ben Finney wrote: Kristján Valur Jónsson writes: Believe it or not, sometimes you really don't care about encodings. Sometimes you just want to parse text files. Files don't contain text, they contain bytes. Bytes

Re: [Python-Dev] Python3 "complexity"

2014-01-08 Thread Lennart Regebro
On Thu, Jan 9, 2014 at 1:07 AM, Ben Finney wrote: > Kristján Valur Jónsson writes: > >> Believe it or not, sometimes you really don't care about encodings. >> Sometimes you just want to parse text files. > > Files don't contain text, they contain bytes. Bytes only become text > when filtered thro

Re: [Python-Dev] Python3 "complexity"

2014-01-08 Thread Stephen J. Turnbull
Ben Finney writes: > That's a much better analogy. The customer may not care, but the > question is essential and must be answered; if the supplier guesses what > the customer wants, they are doing the customer a disservice. It is a much better analogy for me on my desktop, and for programmers

Re: [Python-Dev] Python3 "complexity"

2014-01-08 Thread Stephen J. Turnbull
Kristján Valur Jónsson writes: > Still playing the devil's advocate: > I didn't used to must. Why must I must now? Did the universe just > shift when I fired up python3? No. Go look at the Economist's tag cloud and notice how big "China" and "India" are most days. The universe has been shi

Re: [Python-Dev] Python3 "complexity" (was RFC: PEP 460: Add bytes...)

2014-01-08 Thread Greg Ewing
Kristján Valur Jónsson wrote: all you want is to open that .txt file on the drive and extract some phone numbers and merge in some email addresses. What encoding does the file have? Do I care? Must I care? To some extent, yes. If the encoding happens to be an ascii-compatible one, such as latin

Re: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5

2014-01-08 Thread Stephen J. Turnbull
Antoine Pitrou writes: > However, interpolating a bytes object isn't out of place, and it is > what a minimal "formatting" primitive could do. Something like this? # VERY incomplete pseudo-code class str: # new method # fmtstring has syntax of .format method's spec, ma

Re: [Python-Dev] Python3 "complexity" (was RFC: PEP 460: Add bytes...)

2014-01-08 Thread Dan Stromberg
On Wed, Jan 8, 2014 at 2:04 PM, Kristján Valur Jónsson wrote: > > Believe it or not, sometimes you really don't care about encodings. > Sometimes you just want to parse text files. Python 3 forces you to think > about abstract concepts like encodings when all you want is to open that .txt > fil

Re: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5

2014-01-08 Thread MRAB
On 2014-01-06 13:24, Victor Stinner wrote: Hi, bytes % args and bytes.format(args) are requested by Mercurial and Twisted projects. The issue #3982 was stuck because nobody proposed a complete definition of the "new" features. Here is a try as a PEP. The PEP is a draft with open questions. Firs

Re: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5

2014-01-08 Thread INADA Naoki
> And I think everyone was well intentioned - and python3 covers most of the > bases, but working with binary data is not only a "wire-protocol > programmer's" > problem. Needing a library to wrap bytesthing.format('ascii', > 'surrogateescape') > or some such thing makes python3 less approachable

Re: [Python-Dev] Python3 "complexity"

2014-01-08 Thread Chris Angelico
On Thu, Jan 9, 2014 at 11:21 AM, MRAB wrote: > On the other hand: > > "I need a new battery." > > "What kind of battery?" > > "I don't care!" Or, bringing it back to Python: How do you write a set out to a file? foo = {1, 2, 4, 8, 16, 32} open("foo.txt","w").write(foo) # Uh... nope!

Re: [Python-Dev] Python3 "complexity" (was RFC: PEP 460: Add bytes...)

2014-01-08 Thread Terry Reedy
On 1/8/2014 5:04 PM, Kristján Valur Jónsson wrote: Believe it or not, sometimes you really don't care about encodings. Sometimes you just want to parse text files. Python 3 forces you to think about abstract concepts like encodings when all you want is to open that .txt file on the drive and ex

Re: [Python-Dev] Python3 "complexity" (was RFC: PEP 460: Add bytes...)

2014-01-08 Thread R. David Murray
On Thu, 09 Jan 2014 00:12:57 +, wrote: > I think there might be a different analogy: Having to specify an > encoding is like having strong typing. In Python 2.7, we _can_ forego > that and just duck-type our strings :) Python is a strongly typed language. Saying that python2 let you duck t

Re: [Python-Dev] Python3 "complexity" (was RFC: PEP 460: Add bytes...)

2014-01-08 Thread Mark Lawrence
On 09/01/2014 00:12, Kristján Valur Jónsson wrote: Just to avoid confusion, let me state up front that I am very well aware of encodings and all that, having internationalized one largish app in python 2.x. I know the problems that 2.x had with tracking down the source of errors and understan

Re: [Python-Dev] Python3 "complexity"

2014-01-08 Thread Ben Finney
Kristján Valur Jónsson writes: > I didn't used to must. Why must I must now? Did the universe just > shift when I fired up python3? In a sense, yes. The world of software has been shifting for decades, as a reasult of broader changes in how different segments of humanity have changed their int

Re: [Python-Dev] Python3 "complexity" (was RFC: PEP 460: Add bytes...)

2014-01-08 Thread Kristján Valur Jónsson
Just to avoid confusion, let me state up front that I am very well aware of encodings and all that, having internationalized one largish app in python 2.x. I know the problems that 2.x had with tracking down the source of errors and understand the beautiful concept of encodings on the boundary.

Re: [Python-Dev] Python3 "complexity"

2014-01-08 Thread Ben Finney
MRAB writes: > On 2014-01-09 00:07, Ben Finney wrote: > > Kristján Valur Jónsson writes: > >> Python 3 forces you to think about abstract concepts like encodings > >> when all you want is to open that .txt file on the drive and > >> extract some phone numbers and merge in some email addresses. W

Re: [Python-Dev] Python3 "complexity"

2014-01-08 Thread Kristján Valur Jónsson
Still playing the devil's advocate: I didn't used to must. Why must I must now? Did the universe just shift when I fired up python3? Things were demonstatably working just fine before without doing so. K From: Python-Dev [python-dev-bounces+kristjan=ccp

Re: [Python-Dev] Python3 "complexity"

2014-01-08 Thread Mark Lawrence
On 09/01/2014 00:21, MRAB wrote: "I need a new battery." "What kind of battery?" "I don't care!" A neat summary of the draft requirements specification for Python 2.8. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language

Re: [Python-Dev] Python3 "complexity" (was RFC: PEP 460: Add bytes...)

2014-01-08 Thread Isaac Morland
On Wed, 8 Jan 2014, Kristján Valur Jónsson wrote: Believe it or not, sometimes you really don't care about encodings. Sometimes you just want to parse text files. Python 3 forces you to think about abstract concepts like encodings when all you want is to open that .txt file on the drive and

Re: [Python-Dev] Python3 "complexity"

2014-01-08 Thread MRAB
On 2014-01-09 00:07, Ben Finney wrote: Kristján Valur Jónsson writes: Believe it or not, sometimes you really don't care about encodings. Sometimes you just want to parse text files. Files don't contain text, they contain bytes. Bytes only become text when filtered through the correct encodi

Re: [Python-Dev] Python3 "complexity"

2014-01-08 Thread Ben Finney
Kristján Valur Jónsson writes: > Believe it or not, sometimes you really don't care about encodings. > Sometimes you just want to parse text files. Files don't contain text, they contain bytes. Bytes only become text when filtered through the correct encoding. Python should not guess the encodi

Re: [Python-Dev] Python3 "complexity" (was RFC: PEP 460: Add bytes...)

2014-01-08 Thread R. David Murray
On Wed, 08 Jan 2014 22:04:56 +, wrote: > Believe it or not, sometimes you really don't care about encodings. > Sometimes you just want to parse text files. Python 3 forces you to > think about abstract concepts like encodings when all you want is to > open that .txt file on the drive and extr

Re: [Python-Dev] Python3 "complexity" (was RFC: PEP 460: Add bytes...)

2014-01-08 Thread Victor Stinner
Hi, > Python 3 forces you to think about abstract concepts like encodings when all > you want is to open that .txt file on the drive and extract some phone > numbers and merge in some email addresses. You can open a text file using ascii + surrogateescape, or just open the file in binary. Vic

Re: [Python-Dev] Python3 "complexity" (was RFC: PEP 460: Add bytes...)

2014-01-08 Thread Joao S. O. Bueno
On 8 January 2014 20:04, Kristján Valur Jónsson wrote: > Believe it or not, sometimes you really don't care about encodings. > Sometimes you just want to parse text files. Python 3 forces you to think > about abstract concepts like encodings when all you want is to open that .txt > file on the

Re: [Python-Dev] Python3 "complexity" (was RFC: PEP 460: Add bytes...)

2014-01-08 Thread Kristján Valur Jónsson
Believe it or not, sometimes you really don't care about encodings. Sometimes you just want to parse text files. Python 3 forces you to think about abstract concepts like encodings when all you want is to open that .txt file on the drive and extract some phone numbers and merge in some email a

Re: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5

2014-01-08 Thread Antoine Pitrou
Hi, With Victor's consent, I overhauled PEP 460 and made the feature set more restricted and consistent with the bytes/str separation. However, I also added bytearray into the mix, as bytearray objects should generally support the same operations as bytes (and they can be useful *especially* for

Re: [Python-Dev] Python3 "complexity" (was RFC: PEP 460: Add bytes...)

2014-01-08 Thread R. David Murray
On Wed, 08 Jan 2014 19:22:08 +, "Matt Billenstein" wrote: > I started in Python blissfully unaware of unicode - it was a different time > for > sure, but what I knew from C worked pretty much the same in Python - I could > read some binary data out of a file, twiddle some bits, and write it b

Re: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5

2014-01-08 Thread Daniel Holth
On Wed, Jan 8, 2014 at 2:17 PM, Stefan Behnel wrote: > Victor Stinner, 06.01.2014 14:24: >> Abstract >> >> Add ``bytes % args`` operator and ``bytes.format(args)`` method to >> Python 3.5. > > Here is a counterproposal. Let someone who needs this feature write a > library that does byte s

Re: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5

2014-01-08 Thread Antoine Pitrou
Hi, Another remark about the PEP: it should define bytearray % args and bytearray.format(args) as well. Regards Antoine. On Mon, 6 Jan 2014 14:24:50 +0100 Victor Stinner wrote: > Hi, > > bytes % args and bytes.format(args) are requested by Mercurial and > Twisted projects. The issue #3982

Re: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5

2014-01-08 Thread Matt Billenstein
On Wed, Jan 08, 2014 at 07:12:06PM +0100, Stefan Behnel wrote: > Why can't someone write a third-party library that does what these projects > need, and that works in both Py2 and Py3, so that these projects can be > modified to use that library and thus get on with their porting to Py3? Apologies

Re: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5

2014-01-08 Thread Stefan Behnel
Victor Stinner, 06.01.2014 14:24: > Abstract > > Add ``bytes % args`` operator and ``bytes.format(args)`` method to > Python 3.5. Here is a counterproposal. Let someone who needs this feature write a library that does byte string formatting. That properly handles it, a full featured tool

Re: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5

2014-01-08 Thread Antoine Pitrou
On Wed, 8 Jan 2014 11:59:51 -0700 Eric Snow wrote: > As others have opined, > formatting a bytes object is out of place. However, interpolating a bytes object isn't out of place, and it is what a minimal "formatting" primitive could do. Regards Antoine. ___

Re: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5

2014-01-08 Thread Eric Snow
On Mon, Jan 6, 2014 at 6:24 AM, Victor Stinner wrote: > Abstract > > > Add ``bytes % args`` operator and ``bytes.format(args)`` method to > Python 3.5. > > > Rationale > = > > ``bytes % args`` and ``bytes.format(args)`` have been removed in Python > 2. This operator and this metho

Re: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5

2014-01-08 Thread Antoine Pitrou
On Wed, 8 Jan 2014 11:16:49 -0700 Eric Snow wrote: > > It boils down to 3.5 being *the* target for porting from 2.7. No. Please let's stop being self-deprecating. 3.3 is fine as a porting target, as the many high-profile libraries which have already been ported can attest. > Otherwise we'd be b

Re: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5

2014-01-08 Thread Eric Snow
On Wed, Jan 8, 2014 at 3:40 AM, M.-A. Lemburg wrote: > PS: The PEP mentions having to code for Python 3.0-3.4 as well, > which would don't support the new methods. I think it's perfectly > fine to have newly ported code to require Python 2.7/3.5+. After > all, the porting effort will take some tim

Re: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5

2014-01-08 Thread Stefan Behnel
Victor Stinner, 07.01.2014 19:14: > 2014/1/7 Stefan Behnel: >> Victor Stinner, 06.01.2014 14:24: >>> ``struct.pack()`` is incomplete. For example, a number cannot be >>> formatted as decimal and it does not support padding bytes string. >> >> Then what about extending the struct module in a way tha

Re: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5

2014-01-08 Thread Victor Stinner
2014/1/8 Ethan Furman : >> Therefore you shouldn't accept integers. It does not make sense to >> format 4 as b'4'. > > Agreed. I would have that it would result in b'\x04'. The PEP proposes b'%c' % 4 => b'\x04. Antoine gave me a good argument against supporting b'%s' % int: how would int subclas

Re: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5

2014-01-08 Thread Ethan Furman
On 01/08/2014 02:28 AM, Antoine Pitrou wrote: On Wed, 8 Jan 2014 11:02:19 +0100 Victor Stinner wrote: What does b'%s' % 7 do? See Examples of the PEP: b'a%sc%s' % (b'b', 4) gives b'abc4' [...] And then what? Use the "default" encoding? ASCII? Bytes have no encoding. There are just byte

Re: [Python-Dev] Changing Clinic's output

2014-01-08 Thread Larry Hastings
On 01/08/2014 08:04 AM, Brett Cannon wrote: On Wed, Jan 8, 2014 at 10:46 AM, Larry Hastings > wrote: Yep. And what I was proposing is much the same, except there are a couple extra lines in the "generated code" section. I'd keep the #define for the metho

Re: [Python-Dev] Changing Clinic's output

2014-01-08 Thread Brett Cannon
On Wed, Jan 8, 2014 at 10:46 AM, Larry Hastings wrote: > > > On 01/08/2014 07:33 AM, Brett Cannon wrote: > > So let's make this idea concrete to focus a possible discussion. Using the > example from the Clinic HOWTO and converting to how I see it working: > [...] > > > Yep. And what I was propos

Re: [Python-Dev] Changing Clinic's output

2014-01-08 Thread Larry Hastings
On 01/08/2014 07:33 AM, Brett Cannon wrote: So let's make this idea concrete to focus a possible discussion. Using the example from the Clinic HOWTO and converting to how I see it working: [...] Yep. And what I was proposing is much the same, except there are a couple extra lines in the "g

Re: [Python-Dev] Changing Clinic's output

2014-01-08 Thread Brett Cannon
On Tue, Jan 7, 2014 at 7:07 PM, Larry Hastings wrote: > > > On 01/07/2014 03:38 PM, Brett Cannon wrote: > > On Tue, Jan 7, 2014 at 6:24 PM, Larry Hastings wrote: > >> For what it's worth, if we use the "accumulator" approach I propose >> that the generated code doesn't go at the very end of the

Re: [Python-Dev] Changing Clinic's output

2014-01-08 Thread Larry Hastings
On 01/08/2014 07:08 AM, Barry Warsaw wrote: On Jan 07, 2014, at 10:39 PM, Serhiy Storchaka wrote: Only this option will solve all my issues. How hard would it be to put together some sample branches that provide concrete examples of the various options? My own opinion could easily be influenc

Re: [Python-Dev] Changing Clinic's output

2014-01-08 Thread Barry Warsaw
On Jan 07, 2014, at 10:39 PM, Serhiy Storchaka wrote: >Only this option will solve all my issues. How hard would it be to put together some sample branches that provide concrete examples of the various options? My own opinion could easily be influenced by having some hands-on time with actual co

Re: [Python-Dev] [RELEASED] Python 3.4.0b2

2014-01-08 Thread Nick Coghlan
On 9 January 2014 00:43, Bob Hanson wrote: > When I read this comment of yours, Guido, I immediately started > wondering about this. You may well be right -- indeed, I have a > very old install (c.2007) which has not been updated (other than > one or three new MS "drivers"). > > Perhaps the Python

Re: [Python-Dev] [RELEASED] Python 3.4.0b2

2014-01-08 Thread Bob Hanson
[Top-post fixed (use-case is an exception to the GvR rule ;-) ) and some attributions restored with my additional comments following for the ease of future readers.] TL;DR: Outbound-connection attempts seem to be happening only to me, therefore, most likely not a Python problem -- but some problem

Re: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5

2014-01-08 Thread Daniel Holth
On Tue, Jan 7, 2014 at 10:36 AM, Stephen J. Turnbull wrote: > Daniel Holth writes: > > > Isn't it true that if you have bytes > 127 or surrogate escapes then > > encoding to latin1 is no longer as fast as memcpy? > > Be careful. As phrased, the question makes no sense. You don't "have > bytes"

Re: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5

2014-01-08 Thread Antoine Pitrou
Hi Victor, On Mon, 6 Jan 2014 14:24:50 +0100 Victor Stinner wrote: > Hi, > > bytes % args and bytes.format(args) are requested by Mercurial and > Twisted projects. The issue #3982 was stuck because nobody proposed a > complete definition of the "new" features. Here is a try as a PEP. There is

Re: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5

2014-01-08 Thread M.-A. Lemburg
On 08.01.2014 11:12, Victor Stinner wrote: > Hi, > > 2014/1/8 M.-A. Lemburg : >> I'd simply copy over the Python 2 PyString code and start working >> from there. > > It's not possible to reuse directly all Python 2 code because some > helpers have been modified to work on Unicode. The PEP 460 add

Re: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5

2014-01-08 Thread Antoine Pitrou
On Wed, 8 Jan 2014 11:02:19 +0100 Victor Stinner wrote: > > > What does b'%s' % 7 do? > > See Examples of the PEP: > > b'a%sc%s' % (b'b', 4) gives b'abc4' [...] > > And then what? Use the "default" encoding? ASCII? > > Bytes have no encoding. There are just bytes :-) Therefore you shouldn't a

Re: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5

2014-01-08 Thread Antoine Pitrou
On Wed, 08 Jan 2014 13:51:36 +0900 "Stephen J. Turnbull" wrote: > Benjamin Peterson writes: > > > I agree. This is a very important, much-requested feature for low-level > > networking code. > > I hear it's much-requested, but is there any description of typical > use cases? The ones I've see

Re: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5

2014-01-08 Thread Chris Angelico
On Wed, Jan 8, 2014 at 9:12 PM, Victor Stinner wrote: > IMO some formatting commands must not be implemented. For example, > alignment is used to display something on screen, not in network > protocols or binary file formats. Must not, or need not? I can understand that those sorts of features wo

Re: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5

2014-01-08 Thread Victor Stinner
Hi, 2014/1/8 M.-A. Lemburg : > I'd simply copy over the Python 2 PyString code and start working > from there. It's not possible to reuse directly all Python 2 code because some helpers have been modified to work on Unicode. The PEP 460 adds also more work to other implementations of Python. IMO

Re: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5

2014-01-08 Thread Victor Stinner
Hi, 2014/1/8 Mark Shannon : > I'm opposed to adding methods to bytes for this, as I think it goes against > the reason for the separation of str and bytes in the first place. Well, sometimes practicability beats purity. Many developers complained that Python 3 is too string. The motivation of the

Re: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5

2014-01-08 Thread M.-A. Lemburg
On 06.01.2014 14:24, Victor Stinner wrote: > Hi, > > bytes % args and bytes.format(args) are requested by Mercurial and > Twisted projects. The issue #3982 was stuck because nobody proposed a > complete definition of the "new" features. Here is a try as a PEP. > > The PEP is a draft with open que

Re: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5

2014-01-08 Thread Mark Shannon
On 06/01/14 13:24, Victor Stinner wrote: Hi, bytes % args and bytes.format(args) are requested by Mercurial and [snip] I'm opposed to adding methods to bytes for this, as I think it goes against the reason for the separation of str and bytes in the first place. str objects are pieces of tex