Re: max(), sum(), next()

2008-11-24 Thread Scott David Daniels
David C. Ullrich wrote: In article <[EMAIL PROTECTED]>, Steven D'Aprano <[EMAIL PROTECTED]> wrote: On Fri, 05 Sep 2008 10:22:22 -0500, David C. Ullrich wrote about why max and min shouldn't accept a default argument: Think about all the previously elected female or black presidents of the U

Re: max(), sum(), next()

2008-09-14 Thread Odalrick
[EMAIL PROTECTED] wrote in news:240454f2-14ee-496a-9078-1abbf80a4e64 @m45g2000hsb.googlegroups.com: > castironpi: >> For max and min, why can't you just add your argument to the set >> itself? > > Sometimes that can be done, but in many other situations it's less > easy, like in the example I hav

''.join woes - Re: max(), sum(), next()

2008-09-13 Thread Boris Borcic
I wrote: Tino Wildenhain wrote: [...] sum(['a','b'],'') : sum() can't sum strings [use ''.join(seq) instead] Yes which is a bit bad anyway. I don't think hard wiring it is such a nice idea. You know, walks like a duck, smells like a duck... If it makes sense to handle things differently

Re: max(), sum(), next()

2008-09-13 Thread Boris Borcic
Tino Wildenhain wrote: Hi, Luis Zarrabeitia wrote: Quoting Laszlo Nagy <[EMAIL PROTECTED]>: ... Even better: help(sum) shows === sum(...) sum(sequence, start=0) -> value Returns the sum of a sequence of numbers (NOT strings) plus the value of parameter 'start'. When the

Re: max(), sum(), next()

2008-09-11 Thread Tino Wildenhain
Hi, Luis Zarrabeitia wrote: Quoting Laszlo Nagy <[EMAIL PROTECTED]>: ... Even better: help(sum) shows === sum(...) sum(sequence, start=0) -> value Returns the sum of a sequence of numbers (NOT strings) plus the value of parameter 'start'. When the sequence is empty, retur

Re: max(), sum(), next()

2008-09-10 Thread Terry Reedy
Mensanator wrote: On Sep 10, 5:36 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: Sum(s) replaces reduce(lambda x,y: x+y, s, 0), which was thought to be the most common use of reduce. Sum(s,start) replaces the much less common reduce(lambda x,y: x+y, s, start). Reduce(S, s), where S = sum funct

Re: max(), sum(), next()

2008-09-10 Thread Mensanator
On Sep 10, 5:36 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > Mensanator wrote: > > Are there situations where the sum of an empty > > list should NOT be 0? Of course there are. > > Python Philosopy (my version, for this discussion): >    Make normal things easy; make unusual or difficult things pos

Re: max(), sum(), next()

2008-09-10 Thread Terry Reedy
Mensanator wrote: Are there situations where the sum of an empty list should NOT be 0? Of course there are. Python Philosopy (my version, for this discussion): Make normal things easy; make unusual or difficult things possible. Application: Sum([]) == 0 is normal (90+% of cases). Make t

Re: max(), sum(), next()

2008-09-10 Thread Mensanator
On Sep 7, 3:38 pm, Luis Zarrabeitia <[EMAIL PROTECTED]> wrote: > Quoting Mensanator <[EMAIL PROTECTED]>: > > > Actualy, I already get the behaviour I want. sum([1,None]) > > throws an exception. I don't see why sum([]) doesn't throw > > an exception also > > If you take a "start value" and add to i

Re: max(), sum(), next()

2008-09-10 Thread Luis Zarrabeitia
Quoting Mensanator <[EMAIL PROTECTED]>: > Actualy, I already get the behaviour I want. sum([1,None]) > throws an exception. I don't see why sum([]) doesn't throw > an exception also If you take a "start value" and add to it every element of a list, should the process fail if the list is empty?

Re: max(), sum(), next()

2008-09-09 Thread David C. Ullrich
In article <[EMAIL PROTECTED]>, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Fri, 05 Sep 2008 10:22:22 -0500, David C. Ullrich wrote about why max > and min shouldn't accept a default argument: > > > Think about all the previously elected female or black presidents of the > > US. Which one w

Re: max(), sum(), next()

2008-09-09 Thread David C. Ullrich
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > David C. Ullrich: > > I didn't mention what's below because it doesn't seem > > likely that saying max([]) = -infinity and > > min([]) = +infinity is going to make the OP happy... > > Well, it sounds cute having Neginfinite and Infinite

Re: max(), sum(), next()

2008-09-09 Thread Boris Borcic
castironpi wrote: On Sep 8, 8:54 am, Boris Borcic <[EMAIL PROTECTED]> wrote: David C. Ullrich wrote: (ii) If A is a subset of B then we should have max(A) <= max(B). This requires that max(empty set) be something that's smaller than everything else. So we give up on that. Er, what about insta

Re: max(), sum(), next()

2008-09-08 Thread castironpi
On Sep 8, 8:54 am, Boris Borcic <[EMAIL PROTECTED]> wrote: > David C. Ullrich wrote: > > > (ii) If A is a subset of B then we should have > > max(A) <= max(B). This requires that max(empty set) > > be something that's smaller than everything else. > > So we give up on that. > > Er, what about insta

Re: max(), sum(), next()

2008-09-08 Thread Boris Borcic
David C. Ullrich wrote: (ii) If A is a subset of B then we should have max(A) <= max(B). This requires that max(empty set) be something that's smaller than everything else. So we give up on that. Er, what about instances of variations/elaborations on class Smaller(object) : __cmp__ = lambda

Re: max(), sum(), next()

2008-09-07 Thread Mensanator
On Sep 7, 2:17�pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Sun, 7 Sep 2008 10:30:09 -0700 (PDT), Mensanator <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > On Sep 6, 11:05?pm, Steven D'Aprano <[EMAIL PROTECTED] > > cybersource.com.au> wrote: > > > > Sheesh. That's

Re: max(), sum(), next()

2008-09-07 Thread Mensanator
On Sep 7, 1:17�pm, Patrick Maupin <[EMAIL PROTECTED]> wrote: > On Sep 7, 12:30�pm, Mensanator <[EMAIL PROTECTED]> wrote: > > > On Sep 6, 11:05 pm, Steven D'Aprano <[EMAIL PROTECTED] > > > Sheesh. That's not a problem, because Python is not trying to be a > > > dialect of SQL. > > > And yet, they ad

Re: max(), sum(), next()

2008-09-07 Thread Mensanator
On Sep 7, 3:13�pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Sun, 07 Sep 2008 14:30:09 -0300, Mensanator <[EMAIL PROTECTED]> escribi�: > > > > > Actualy, I already get the behaviour I want. sum([1,None]) > > throws an exception. I don't see why sum([]) doesn't throw > > an exception also

Re: max(), sum(), next()

2008-09-07 Thread James Mills
Can we stop this thread now? :) I think we've all seen what the intended behavior of sum(), max() and other similar functions. cheers James On Mon, Sep 8, 2008 at 3:30 AM, Mensanator <[EMAIL PROTECTED]> wrote: > On Sep 6, 11:05�pm, Steven D'Aprano <[EMAIL PROTECTED] > cybersource.com.au> wrote:

Re: max(), sum(), next()

2008-09-07 Thread Gabriel Genellina
En Sun, 07 Sep 2008 14:30:09 -0300, Mensanator <[EMAIL PROTECTED]> escribió: > Actualy, I already get the behaviour I want. sum([1,None]) > throws an exception. I don't see why sum([]) doesn't throw > an exception also (I understand that behaviour is by design, > I'm merely pointing out that the d

Re: max(), sum(), next()

2008-09-07 Thread Patrick Maupin
On Sep 7, 12:30 pm, Mensanator <[EMAIL PROTECTED]> wrote: > On Sep 6, 11:05 pm, Steven D'Aprano <[EMAIL PROTECTED] > > Sheesh. That's not a problem, because Python is not trying to be a > > dialect of SQL. > > And yet, they added a Sqlite3 module. Does that mean that, because there is an 'os' modu

Re: max(), sum(), next()

2008-09-07 Thread Mensanator
On Sep 6, 11:05�pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Sat, 06 Sep 2008 11:22:07 -0700, Mensanator wrote: > > [...] > > >> They could have decided that sum must take at least two arguments, > >> because addition requires two arguments and it's meaningless to talk > >

Re: max(), sum(), next()

2008-09-06 Thread Steven D'Aprano
On Sat, 06 Sep 2008 11:22:07 -0700, Mensanator wrote: [...] >> They could have decided that sum must take at least two arguments, >> because addition requires two arguments and it's meaningless to talk >> about adding a single number without talking about adding it to >> something else. But they

Re: max(), sum(), next()

2008-09-06 Thread Hendrik van Rooyen
"David C. Ullrich" wrote: >Think about all the previously elected female or black >presidents of the US. Which one was the tallest? The current King of France? - Hendrik -- http://mail.python.org/mailman/listinfo/python-list

Re: max(), sum(), next()

2008-09-06 Thread Mensanator
On Sep 5, 10:45�pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Fri, 05 Sep 2008 22:20:06 -0400, Manu Hack wrote: > > On Fri, Sep 5, 2008 at 1:04 PM, castironpi <[EMAIL PROTECTED]> wrote: > [The rest of this is (mostly) aimed at Mensanator, Ok, I see where you're coming f

Re: max(), sum(), next()

2008-09-06 Thread Mel
Steven D'Aprano wrote: > On Sat, 06 Sep 2008 00:33:25 -0400, Manu Hack wrote: > >> Actually it's even more natural to state sum([x]) = x, and this way you >> can never conclude that sum([]) = 0 from there. > > But what you can say is that for any list L, sum(L) = sum(L + [0]). > > Therefore sum

Re: max(), sum(), next()

2008-09-06 Thread Ken Starks
castironpi wrote: On Sep 5, 9:20 pm, "Manu Hack" <[EMAIL PROTECTED]> wrote: On Fri, Sep 5, 2008 at 1:04 PM, castironpi <[EMAIL PROTECTED]> wrote: On Sep 5, 3:28 am, "Manu Hack" <[EMAIL PROTECTED]> wrote: On Thu, Sep 4, 2008 at 4:25 PM, castironpi <[EMAIL PROTECTED]> wrote: On Sep 4, 2:42 pm,

Re: max(), sum(), next()

2008-09-06 Thread Ken Starks
castironpi wrote: On Sep 5, 9:20 pm, "Manu Hack" <[EMAIL PROTECTED]> wrote: On Fri, Sep 5, 2008 at 1:04 PM, castironpi <[EMAIL PROTECTED]> wrote: On Sep 5, 3:28 am, "Manu Hack" <[EMAIL PROTECTED]> wrote: On Thu, Sep 4, 2008 at 4:25 PM, castironpi <[EMAIL PROTECTED]> wrote: On Sep 4, 2:42 pm,

Re: max(), sum(), next()

2008-09-06 Thread Manu Hack
On Sat, Sep 6, 2008 at 12:57 AM, castironpi <[EMAIL PROTECTED]> wrote: > On Sep 5, 9:20 pm, "Manu Hack" <[EMAIL PROTECTED]> wrote: >> On Fri, Sep 5, 2008 at 1:04 PM, castironpi <[EMAIL PROTECTED]> wrote: >> > On Sep 5, 3:28 am, "Manu Hack" <[EMAIL PROTECTED]> wrote: >> >> On Thu, Sep 4, 2008 at 4:2

Re: max(), sum(), next()

2008-09-06 Thread Steven D'Aprano
On Sat, 06 Sep 2008 00:33:25 -0400, Manu Hack wrote: > Actually it's even more natural to state sum([x]) = x, and this way you > can never conclude that sum([]) = 0 from there. But what you can say is that for any list L, sum(L) = sum(L + [0]). Therefore sum([]) = sum([] +[0]) = 0 -- Steven

Re: max(), sum(), next()

2008-09-05 Thread castironpi
On Sep 5, 9:20 pm, "Manu Hack" <[EMAIL PROTECTED]> wrote: > On Fri, Sep 5, 2008 at 1:04 PM, castironpi <[EMAIL PROTECTED]> wrote: > > On Sep 5, 3:28 am, "Manu Hack" <[EMAIL PROTECTED]> wrote: > >> On Thu, Sep 4, 2008 at 4:25 PM, castironpi <[EMAIL PROTECTED]> wrote: > >> > On Sep 4, 2:42 pm, [EMAIL

Re: max(), sum(), next()

2008-09-05 Thread Manu Hack
On Fri, Sep 5, 2008 at 11:45 PM, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Fri, 05 Sep 2008 22:20:06 -0400, Manu Hack wrote: > >> On Fri, Sep 5, 2008 at 1:04 PM, castironpi <[EMAIL PROTECTED]> wrote: > ... >The reason sum([]) is 0 is that sum( [ x ] ) - x = 0. It doesn't make s

Re: max(), sum(), next()

2008-09-05 Thread Steven D'Aprano
On Fri, 05 Sep 2008 22:20:06 -0400, Manu Hack wrote: > On Fri, Sep 5, 2008 at 1:04 PM, castironpi <[EMAIL PROTECTED]> wrote: ... >>> >The reason sum([]) is 0 is that sum( [ x ] ) - x = 0. >>> >>> It doesn't make sense to me. What do you set x to? >> >> For all x. > > But then how can you conclud

Re: max(), sum(), next()

2008-09-05 Thread Manu Hack
On Fri, Sep 5, 2008 at 1:04 PM, castironpi <[EMAIL PROTECTED]> wrote: > On Sep 5, 3:28 am, "Manu Hack" <[EMAIL PROTECTED]> wrote: >> On Thu, Sep 4, 2008 at 4:25 PM, castironpi <[EMAIL PROTECTED]> wrote: >> > On Sep 4, 2:42 pm, [EMAIL PROTECTED] wrote: >> >> David C. Ullrich: >> >> >> > At least in

Re: max(), sum(), next()

2008-09-05 Thread Steven D'Aprano
On Fri, 05 Sep 2008 10:22:22 -0500, David C. Ullrich wrote about why max and min shouldn't accept a default argument: > Think about all the previously elected female or black presidents of the > US. Which one was the tallest? I know the answer to that one: All of them! -- Steven -- http://

Re: max(), sum(), next()

2008-09-05 Thread Ken Starks
David C. Ullrich wrote: In article <[EMAIL PROTECTED]>, Ken Starks <[EMAIL PROTECTED]> wrote: David C. Ullrich wrote: I don't see why you feel the two should act the same. At least in mathematics, the sum of the elements of the empty set _is_ 0, while the maximum element of the empty set is

Re: max(), sum(), next()

2008-09-05 Thread Mensanator
On Sep 5, 1:08 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Thu, 4 Sep 2008 18:09:49 -0700 (PDT), Mensanator <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > Too bad. I brought this up because I use Python a lot with > > database work and rarely for proving theorms

Re: max(), sum(), next()

2008-09-05 Thread castironpi
On Sep 5, 3:28 am, "Manu Hack" <[EMAIL PROTECTED]> wrote: > On Thu, Sep 4, 2008 at 4:25 PM, castironpi <[EMAIL PROTECTED]> wrote: > > On Sep 4, 2:42 pm, [EMAIL PROTECTED] wrote: > >> David C. Ullrich: > > >> > At least in mathematics, the sum of the elements of > >> > the empty set _is_ 0, while th

Re: max(), sum(), next()

2008-09-05 Thread bearophileHUGS
David C. Ullrich: > I didn't mention what's below because it doesn't seem > likely that saying max([]) = -infinity and > min([]) = +infinity is going to make the OP happy... Well, it sounds cute having Neginfinite and Infinite as built-int objects that can be compared to any other type and are < o

Re: max(), sum(), next()

2008-09-05 Thread David C. Ullrich
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > David C. Ullrich: > > At least in mathematics, the sum of the elements of > > the empty set _is_ 0, while the maximum element of the > > empty set is undefined. > > What do you think about my idea of adding that 'default' argument to >

Re: max(), sum(), next()

2008-09-05 Thread David C. Ullrich
In article <[EMAIL PROTECTED]>, Ken Starks <[EMAIL PROTECTED]> wrote: > David C. Ullrich wrote: > > > > > I don't see why you feel the two should act the same. > > At least in mathematics, the sum of the elements of > > the empty set _is_ 0, while the maximum element of the > > empty set is und

Re: max(), sum(), next()

2008-09-05 Thread Ken Starks
David C. Ullrich wrote: I don't see why you feel the two should act the same. At least in mathematics, the sum of the elements of the empty set _is_ 0, while the maximum element of the empty set is undefined. And both for good reason: (i) If A and B are disjoint sets we certainly want to ha

Re: max(), sum(), next()

2008-09-05 Thread Ken Starks
David C. Ullrich wrote: In article <[EMAIL PROTECTED]>, Mensanator <[EMAIL PROTECTED]> wrote: On Sep 3, 2:18 pm, Laszlo Nagy <[EMAIL PROTECTED]> wrote: [EMAIL PROTECTED] wrote: Empty Python lists [] don't know the type of the items it will contain, so this sounds strange: sum([]) 0 Becaus

Re: max(), sum(), next()

2008-09-05 Thread Manu Hack
On Thu, Sep 4, 2008 at 4:25 PM, castironpi <[EMAIL PROTECTED]> wrote: > On Sep 4, 2:42 pm, [EMAIL PROTECTED] wrote: >> David C. Ullrich: >> >> > At least in mathematics, the sum of the elements of >> > the empty set _is_ 0, while the maximum element of the >> > empty set is undefined. >> >> What do

Re: max(), sum(), next()

2008-09-04 Thread Mensanator
On Sep 4, 12:31 pm, Thomas Bellman <[EMAIL PROTECTED]> wrote: > Mensanator <[EMAIL PROTECTED]> wrote: > > Ok, but I don't understand why an empty list is a valid sum > > whereas a list containing None is not. > > You can't conclude the behaviour of the one from the behaviour > of the other, because

Re: max(), sum(), next()

2008-09-04 Thread Thomas Bellman
Mensanator <[EMAIL PROTECTED]> wrote: > Ok, but I don't understand why an empty list is a valid sum > whereas a list containing None is not. You can't conclude the behaviour of the one from the behaviour of the other, because the two situations have nothing at all in common. >> As it happens, th

Re: max(), sum(), next()

2008-09-04 Thread bearophileHUGS
castironpi: > For max and min, why can't you just add your argument to the set > itself? Sometimes that can be done, but in many other situations it's less easy, like in the example I have shown in my first post: max((fun(x) for x in iterable if predicate(x))) There are some ways to add the max

Re: max(), sum(), next()

2008-09-04 Thread castironpi
On Sep 4, 2:42 pm, [EMAIL PROTECTED] wrote: > David C. Ullrich: > > > At least in mathematics, the sum of the elements of > > the empty set _is_ 0, while the maximum element of the > > empty set is undefined. > > What do you think about my idea of adding that 'default' argument to > the max()/min()

Re: max(), sum(), next()

2008-09-04 Thread bearophileHUGS
David C. Ullrich: > At least in mathematics, the sum of the elements of > the empty set _is_ 0, while the maximum element of the > empty set is undefined. What do you think about my idea of adding that 'default' argument to the max()/min() functions? Bye, bearophile -- http://mail.python.org/mail

Re: max(), sum(), next()

2008-09-04 Thread Wojtek Walczak
On Thu, 4 Sep 2008 10:57:35 -0700 (PDT), Mensanator wrote: > Why then, doesn't > sum([A for A in [None, None, None, None, None, None] if A != None]) > 0 > > give me an error? Because "[A for A in [None, None, None, None, None, None] if A != None]" returns an empty list, and sum([]) doesn't r

Re: max(), sum(), next()

2008-09-04 Thread Mensanator
On Sep 4, 2:05 am, Thomas Bellman <[EMAIL PROTECTED]> wrote: > Mensanator <[EMAIL PROTECTED]> wrote: > > No, but blank cells are 0 as far as Excel is concerned. > > That behaviour causes nothing but trouble and I am > > saddened to see Python emulate such nonsense. > > Then you should feel glad tha

Re: max(), sum(), next()

2008-09-04 Thread Mensanator
On Sep 4, 11:13 am, "David C. Ullrich" <[EMAIL PROTECTED]> wrote: > In article > <[EMAIL PROTECTED]>, > > > > > >  Mensanator <[EMAIL PROTECTED]> wrote: > > On Sep 3, 2:18 pm, Laszlo Nagy <[EMAIL PROTECTED]> wrote: > > > [EMAIL PROTECTED] wrote: > > > > Empty Python lists [] don't know the type of

Re: max(), sum(), next()

2008-09-04 Thread David C. Ullrich
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > Empty Python lists [] don't know the type of the items it will > contain, so this sounds strange: > > >>> sum([]) > 0 > > Because that [] may be an empty sequence of someobject: > > >>> sum(s for s in ["a", "b"] if len(s) > 2) > 0 >

Re: max(), sum(), next()

2008-09-04 Thread David C. Ullrich
In article <[EMAIL PROTECTED]>, Mensanator <[EMAIL PROTECTED]> wrote: > On Sep 3, 2:18 pm, Laszlo Nagy <[EMAIL PROTECTED]> wrote: > > [EMAIL PROTECTED] wrote: > > > Empty Python lists [] don't know the type of the items it will > > > contain, so this sounds strange: > > > > sum([]) > > > >

Re: max(), sum(), next()

2008-09-04 Thread Thomas Bellman
Mensanator <[EMAIL PROTECTED]> wrote: > No, but blank cells are 0 as far as Excel is concerned. > That behaviour causes nothing but trouble and I am > saddened to see Python emulate such nonsense. Then you should feel glad that the Python sum() function *does* signal an error for the closest equi

Re: max(), sum(), next()

2008-09-04 Thread Mensanator
On Sep 4, 1:26 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Wed, 03 Sep 2008 22:20:43 -0700, Mensanator wrote: > > On Sep 3, 8:30 pm, Steven D'Aprano <[EMAIL PROTECTED] > > cybersource.com.au> wrote: > >> On Wed, 03 Sep 2008 16:20:39 -0700, Mensanator wrote: > >> sum(

Re: max(), sum(), next()

2008-09-03 Thread Steven D'Aprano
On Wed, 03 Sep 2008 22:20:43 -0700, Mensanator wrote: > On Sep 3, 8:30�pm, Steven D'Aprano <[EMAIL PROTECTED] > cybersource.com.au> wrote: >> On Wed, 03 Sep 2008 16:20:39 -0700, Mensanator wrote: >> sum([]) >> > 0 >> >> > is a bug, just as it's a bug in Excel to evaluate blank cells as 0. >>

Re: max(), sum(), next()

2008-09-03 Thread Fredrik Lundh
Mensanator wrote: No it isn't. Nothing is not 0, check with MS-Access, for instance: Null + 1 returns Null. Any arithmetic expression involving a Null evaluates to Null. Adding something to an unknown returns an unknown, as it should. It is a logical fallacy to equate unknown with 0. http://

Re: max(), sum(), next()

2008-09-03 Thread Mensanator
On Sep 4, 12:20�am, Mensanator <[EMAIL PROTECTED]> wrote: > On Sep 3, 8:30 pm, Steven D'Aprano <[EMAIL PROTECTED] > > cybersource.com.au> wrote: > > On Wed, 03 Sep 2008 16:20:39 -0700, Mensanator wrote: > > sum([]) > > > 0 > > > > is a bug, just as it's a bug in Excel to evaluate blank cells a

Re: max(), sum(), next()

2008-09-03 Thread Mensanator
On Sep 3, 8:30�pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Wed, 03 Sep 2008 16:20:39 -0700, Mensanator wrote: > sum([]) > > 0 > > > is a bug, just as it's a bug in Excel to evaluate blank cells as 0. It > > should return None or throw an exception like sum([None,1])

Re: max(), sum(), next()

2008-09-03 Thread Luis Zarrabeitia
Quoting Laszlo Nagy <[EMAIL PROTECTED]>: > [EMAIL PROTECTED] wrote: > > Empty Python lists [] don't know the type of the items it will > > contain, so this sounds strange: > > > > > sum([]) > > > 0 > > > > Because that [] may be an empty sequence of someobject: > > > > Y

Re: max(), sum(), next()

2008-09-03 Thread Steven D'Aprano
On Wed, 03 Sep 2008 16:20:39 -0700, Mensanator wrote: sum([]) > 0 > > is a bug, just as it's a bug in Excel to evaluate blank cells as 0. It > should return None or throw an exception like sum([None,1]) does. You're wrong, because 99.9% of the time when users leave a blank cell in Excel, t

Re: max(), sum(), next()

2008-09-03 Thread castironpi
On Sep 3, 7:48 am, [EMAIL PROTECTED] wrote: > Empty Python lists [] don't know the type of the items it will > contain, so this sounds strange: > > >>> sum([]) > > 0 > > Because that [] may be an empty sequence of someobject: > > >>> sum(s for s in ["a", "b"] if len(s) > 2) > > 0 > > In a staticall

Re: max(), sum(), next()

2008-09-03 Thread Mensanator
On Sep 3, 2:18 pm, Laszlo Nagy <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > Empty Python lists [] don't know the type of the items it will > > contain, so this sounds strange: > > sum([]) > > > 0 > > > Because that [] may be an empty sequence of someobject: > > You are right in th

Re: max(), sum(), next()

2008-09-03 Thread bearophileHUGS
Laszlo Nagy: > I believe that there have been excessive discussions about this > decision, and the current implementation is very good, if not the best. I see. But note that my post is mostly about the max()/min() functions :-) Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-lis

Re: max(), sum(), next()

2008-09-03 Thread MRAB
On Sep 3, 8:18 pm, Laszlo Nagy <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > Empty Python lists [] don't know the type of the items it will > > contain, so this sounds strange: > > sum([]) > > > 0 > > > Because that [] may be an empty sequence of someobject: > > You are right in th

Re: max(), sum(), next()

2008-09-03 Thread Laszlo Nagy
[EMAIL PROTECTED] wrote: Empty Python lists [] don't know the type of the items it will contain, so this sounds strange: sum([]) 0 Because that [] may be an empty sequence of someobject: You are right in that sum could be used to sum arbitrary objects. However, in 99.99% of

Re: max(), sum(), next()

2008-09-03 Thread Sion Arrowsmith
<[EMAIL PROTECTED]> wrote: >Empty Python lists [] don't know the type of the items it will >contain, so this sounds strange: > sum([]) >0 >>> help(sum) sum(...) sum(sequence, start=0) -> value >>> sum(range(x) for x in range(5)) Traceback (most recent call last): File "", line 1, in