max(), sum(), next()
mensanator at aol.com
Mon Sep 8 02:22:21 CEST 2008
On Sep 7, 3:13�pm, "Gabriel Genellina" <gagsl-... at yahoo.com.ar> wrote:
> En Sun, 07 Sep 2008 14:30:09 -0300, Mensanator <mensana... at aol.com> 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 design doesn't cover every
> > situation).
> > Exactly. That's why I would prefer sum() to raise an
> > exception instead of giving a false positive.
> The built in behavior can't be good for every usage. Nobody prevents you from defining yoru own function tailored to your own specs, like this:
> def strict_sum(items):
> � � items = iter(items)
> � � try:
> � � � � first = items.next()
> � � except StopIteration:
> � � � � raise ValueError, "strict_sum with empty argument"
> � � return sum(items, first)
> Tweak as needed. Based on other posts I believe your Python skills are enough to write it on your own, so I don't see why you're complaining so hard about the current behavior.
I'm not complaining about the behaviour anymore, I just don't like
being told I'm wrong when I'm not.
But I think I've made my point, so there's no point in harping on
> Gabriel Genellina
More information about the Python-list