Re: [Python-Dev] Rationale for sum()'s design?

2005-03-15 Thread Nick Coghlan
Guido van Rossum wrote: On Tue, 15 Mar 2005 00:05:32 +1000, Nick Coghlan [EMAIL PROTECTED] wrote: ... try: ... value += first ... except TypeError: ... raise TypeError(Cannot add first element %r to initial value %r % (first, value)) No, no, no! NO! Never catch a general exception

Re: [Python-Dev] code blocks using 'for' loops and generators

2005-03-15 Thread Samuele Pedroni
Brian Sabbey wrote: Samuele Pedroni wrote: OTOH a suite-based syntax for thunks can likely not work as a substitute of lambda for cases like: f(lambda: ..., ...) where the function is the first argument, and then there are further arguments. I do not see why you say suite-based thunks cannot

Re: [Python-Dev] Rationale for sum()'s design?

2005-03-15 Thread Nick Coghlan
Guido van Rossum wrote: I think the conclusion should be that sum() is sufficiently constrained by backwards compatibility to make fixing it impossible before 3.0. But in 3.0 I'd like to fix it so that the 2nd argument is only used for empty lists. Two questions about this: 1. When omitting the

Re: [Python-Dev] Rationale for sum()'s design?

2005-03-15 Thread Guido van Rossum
On Tue, 15 Mar 2005 22:21:07 +1000, Nick Coghlan [EMAIL PROTECTED] wrote: Guido van Rossum wrote: I think the conclusion should be that sum() is sufficiently constrained by backwards compatibility to make fixing it impossible before 3.0. But in 3.0 I'd like to fix it so that the 2nd

RE: [Python-Dev] Rationale for sum()'s design?

2005-03-15 Thread Batista, Facundo
Title: RE: [Python-Dev] Rationale for sum()'s design? [Guido van Rossum] #- 1. When omitting the second argument, would supplying an #- empty list return 0, #- None or raise an exception? #- #- Good question... I'd go for None: - Is a good default for a non-existing argument. - If

Re: [Python-Dev] Rationale for sum()'s design?

2005-03-15 Thread Paul Moore
On Mon, 14 Mar 2005 17:57:42 -0800, Guido van Rossum [EMAIL PROTECTED] wrote: Unfortunately this started when I claimed in my blog that sum() was a replacement for 80% of all reduce() uses. That's probably where the error lies, then. When it was introduced, sum() was for summing numbers.

[Python-Dev] Re: Rationale for sum()'s design?

2005-03-15 Thread Terry Reedy
Michael Chermside [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Tim writes: I'd personally be delighted if sum() never worked on anything other than numbers. Guido writes: I think the conclusion should be that sum() is sufficiently constrained by backwards compatibility to

Re: [Python-Dev] Rationale for sum()'s design?

2005-03-15 Thread Guido van Rossum
[Guido] Unfortunately this started when I claimed in my blog that sum() was a replacement for 80% of all reduce() uses. [Paul] That's probably where the error lies, then. When it was introduced, sum() was for summing numbers. Um, Python doesn't provide a lot of special support for numbers

RE: [Python-Dev] Rationale for sum()'s design?

2005-03-15 Thread Batista, Facundo
Title: RE: [Python-Dev] Rationale for sum()'s design? [Guido van Rossum] #- 3.0 is soon?!? *You* should answer this, ;) . Facundo Bitácora De Vuelo: http://www.taniquetil.com.ar/plog PyAr - Python Argentina: http://pyar.decode.com.ar/ . . . . . . . . . . . . . . . . . . . . . . .

Re: [Python-Dev] Rationale for sum()'s design?

2005-03-15 Thread Tim Peters
[Guido van Rossum] Um, Python doesn't provide a lot of special support for numbers apart from literals -- sum() should support everything that supports the + operator, just like min() and max() support everything that supports comparison, etc. The discussion in the patch that introduced it

Re: [Python-Dev] code blocks using 'for' loops and generators

2005-03-15 Thread Brian Sabbey
Samuele Pedroni wrote: My point is that a suite-based syntax can only be a half substitute for lambda and anyway requiring a suite seems overkill and unnatural for the just 1 expression case, for example predicates. IOW a suite-based syntax is not a lambda killer in itself, I would not try to

Re: [Python-Dev] comprehension abbreviation (was: Adding any() and all())

2005-03-15 Thread Eric Nieuwland
Martin v. Löwis wrote: That's not the full syntax. The full syntax is [ test for exprlist in testlist list-iter-opt ] where test can be an arbitrary expression: and, or, lambda, +, -, ... exprlist can be a list of expression, except for boolean and relational expressions (but I think this is

Re: [Python-Dev] comprehension abbreviation (was: Adding any() and all())

2005-03-15 Thread Brett C.
Eric Nieuwland wrote: Martin v. Löwis wrote: That's not the full syntax. The full syntax is [ test for exprlist in testlist list-iter-opt ] where test can be an arbitrary expression: and, or, lambda, +, -, ... exprlist can be a list of expression, except for boolean and relational expressions

Re: [Python-Dev] Rationale for sum()'s design?

2005-03-15 Thread Alex Martelli
On Mar 15, 2005, at 01:16, Tim Peters wrote: [Eric Nieuwland] Perhaps the second argument should not be optional to emphasise this. After all, there's much more to sum() than numbers. [Greg Ewing] I think practicality beats purity here. Using it on numbers is surely an extremely common case. I'd

Re: [Python-Dev] comprehension abbreviation

2005-03-15 Thread Martin v. Löwis
Eric Nieuwland wrote: [ test for exprlist in testlist list-iter-opt ] Aren't these names a bit mixed up w.r.t. what's in that position? It comes more-or-less straight out of Grammar/Grammar, so: no, I don't think so. As far as I know test is not a test but a function as it produces any value

[Python-Dev] RE: code blocks using 'for' loops and generators

2005-03-15 Thread Jim Jewett
It may be time to PEP (or re-PEP), if only to clarify what people are actually asking for. Brian Sabbey's example from message http://mail.python.org/pipermail/python-dev/2005-March/052202.html *seems* reasonably clear, but I don't see how it relates in any way to for loops or generators,

[Python-Dev] Re: Rationale for sum()'s design?

2005-03-15 Thread Nicolas Fleury
Nick Coghlan wrote: Guido van Rossum wrote: No, no, no! NO! Never catch a general exception like that and replace it with one of your own. That can cause hours of debugging pain later on when the type error is deep down in the bowels of the += operation (or perhaps deep down inside something *it*

[Python-Dev] Re: comprehension abbreviation (was: Adding any() and all())

2005-03-15 Thread Jim Jewett
Gareth McCaughan wrote: Some bit of my brain is convinced that [x in stuff if condition] is the Right Syntax and keeps making me type it even though I know it doesn't work. (and I agree with Gareth) On Monday 2005-03-14 12:42, Eric Nieuwland wrote: The full syntax is: [ f(x) for x in seq

Re: [Python-Dev] RE: code blocks using 'for' loops and generators

2005-03-15 Thread Samuele Pedroni
Jim Jewett wrote: It may be time to PEP (or re-PEP), if only to clarify what people are actually asking for. Brian Sabbey's example from message http://mail.python.org/pipermail/python-dev/2005-March/052202.html *seems* reasonably clear, but I don't see how it relates in any way to for loops or

Re: [Python-Dev] Rationale for sum()'s design?

2005-03-15 Thread Tim Peters
[Alex Martelli] I'm reasonably often using sum on lists of datetime.timedelta instances, durations, which ARE summable just like numbers even though they aren't numbers. I believe everything else for which I've used sum in production code DOES come under the general concept of numbers, in

Re: [Python-Dev] (no subject)

2005-03-15 Thread Phillip J. Eby
At 10:36 PM 3/15/05 +1000, Nick Coghlan wrote: Phillip J. Eby wrote: I discussed this approach with Guido in private e-mail a few months back during discussion about an article I was writing for DDJ about decorators. We also discussed something very similar to 'update_meta()', but never