Re: [Python-Dev] sum(...) limitation

2014-08-12 Thread Stephen J. Turnbull
Ethan Furman writes: On 08/11/2014 08:50 PM, Stephen J. Turnbull wrote: Chris Barker - NOAA Federal writes: It seems pretty pedantic to say: we could make this work well, but we'd rather chide you for not knowing the proper way to do it. Nobody disagrees. But backward

Re: [Python-Dev] sum(...) limitation

2014-08-12 Thread Nick Coghlan
On 12 Aug 2014 11:21, Chris Barker - NOAA Federal chris.bar...@noaa.gov wrote: Sorry for the bike shedding here, but: The quadratic behaviour of repeated str summation is a subtle, silent error. OK, fair enough. I suppose it would be hard and ugly to catch those instances and raise an

Re: [Python-Dev] sum(...) limitation

2014-08-12 Thread Armin Rigo
Hi all, The core of the matter is that if we repeatedly __add__ strings from a long list, we get O(n**2) behavior. For one point of view, the reason is that the additions proceed in left-to-right order. Indeed, sum() could proceed in a more balanced tree-like order: from [x0, x1, x2, x3, ...],

Re: [Python-Dev] Multiline with statement line continuation

2014-08-12 Thread Devin Jeanpierre
I think this thread is probably Python-Ideas territory... On Mon, Aug 11, 2014 at 4:08 PM, Allen Li cyberdup...@gmail.com wrote: Currently, this works with explicit line continuation, but as all style guides favor implicit line continuation over explicit, it would be nice if you could do the

Re: [Python-Dev] Multiline with statement line continuation

2014-08-12 Thread Steven D'Aprano
On Tue, Aug 12, 2014 at 10:28:14AM +1000, Nick Coghlan wrote: On 12 Aug 2014 09:09, Allen Li cyberdup...@gmail.com wrote: This is a problem I sometimes run into when working with a lot of files simultaneously, where I need three or more `with` statements: with open('foo') as foo:

Re: [Python-Dev] Multiline with statement line continuation

2014-08-12 Thread Ian Cordasco
On Tue, Aug 12, 2014 at 7:15 AM, Steven D'Aprano st...@pearwood.info wrote: On Tue, Aug 12, 2014 at 10:28:14AM +1000, Nick Coghlan wrote: On 12 Aug 2014 09:09, Allen Li cyberdup...@gmail.com wrote: This is a problem I sometimes run into when working with a lot of files simultaneously,

Re: [Python-Dev] Multiline with statement line continuation

2014-08-12 Thread Guido van Rossum
On Tue, Aug 12, 2014 at 3:43 AM, Devin Jeanpierre jeanpierr...@gmail.com wrote: I think this thread is probably Python-Ideas territory... On Mon, Aug 11, 2014 at 4:08 PM, Allen Li cyberdup...@gmail.com wrote: Currently, this works with explicit line continuation, but as all style guides

Re: [Python-Dev] Multiline with statement line continuation

2014-08-12 Thread Armin Rigo
Hi, On 12 August 2014 01:08, Allen Li cyberdup...@gmail.com wrote: with (open('foo') as foo, open('bar') as bar, open('baz') as baz, open('spam') as spam, open('eggs') as eggs): pass +1. It's exactly the same grammar extension as for

Re: [Python-Dev] Multiline with statement line continuation

2014-08-12 Thread Georg Brandl
On 08/12/2014 06:57 PM, Armin Rigo wrote: Hi, On 12 August 2014 01:08, Allen Li cyberdup...@gmail.com wrote: with (open('foo') as foo, open('bar') as bar, open('baz') as baz, open('spam') as spam, open('eggs') as eggs): pass +1.

Re: [Python-Dev] sum(...) limitation

2014-08-12 Thread Chris Barker
On Mon, Aug 11, 2014 at 11:07 PM, Stephen J. Turnbull step...@xemacs.org wrote: I'm referring to removing the unnecessary information that there's a better way to do it, and simply raising an error (as in Python 3.2, say) which is all a RealProgrammer[tm] should ever need! I can't imagine

Re: [Python-Dev] sum(...) limitation

2014-08-12 Thread Stefan Richthofer
I know, I have nothing to decide here, since Im no contributer and just a silent watcher on this list. However I just wanted to point out I fully agree with Chris Barkers position. Couldnt have stated it better. Performance should be interpreter implementation issue, not language issue. 2)

Re: [Python-Dev] Multiline with statement line continuation

2014-08-12 Thread Devin Jeanpierre
On Tue, Aug 12, 2014 at 8:12 AM, Guido van Rossum gu...@python.org wrote: On Tue, Aug 12, 2014 at 3:43 AM, Devin Jeanpierre jeanpierr...@gmail.com wrote: The parentheses seem unnecessary/redundant/weird. Why not allow newlines in-between with and the terminating :? with open('foo') as foo,

Re: [Python-Dev] sum(...) limitation

2014-08-12 Thread Nikolaus Rath
Chris Barker chris.bar...@noaa.gov writes: What I fail to see is why it's better to raise an exception and point users to a better way, than to simply provide an optimization so that it's a mute issue. The only justification offered here is that will teach people that summing strings (and

Re: [Python-Dev] Multiline with statement line continuation

2014-08-12 Thread Steven D'Aprano
On Tue, Aug 12, 2014 at 08:04:35AM -0500, Ian Cordasco wrote: I think by introducing parentheses we are going to risk seriously confusing users who may then try to write an assignment like a = (open('spam') as spam, open('eggs') as eggs) Seriously? If they try it, they will get a syntax