[New-bugs-announce] [issue14451] sum, min, max only works with iterable

Fade78 report at bugs.python.org
Fri Mar 30 12:18:26 CEST 2012


New submission from Fade78 <fade at wanadoo.fr>:

The built-in functions working with iterable should also work with single object that is relevent.

For example:
max([1,6,5]) -> 6
max(6) -> TypeError because not an iterable (actual behavior)
max(6) -> 6 (wanted pythonic behavior)

So if I write a generic function like this:

def f(x):
    totalsum+=sum(x)

it fails if x is not an iterable. But I want the argument to be anything possible. Using if(type) to separate use cases is not very pythonic.

----------
components: None
messages: 157133
nosy: Fade78
priority: normal
severity: normal
status: open
title: sum, min, max only works with iterable
type: behavior
versions: Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14451>
_______________________________________


More information about the New-bugs-announce mailing list