Title: sum, min, max only works with iterable
Type: behavior Stage: resolved
Components: None Versions: Python 3.2
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: Fade78, r.david.murray
Priority: normal Keywords:

Created on 2012-03-30 10:18 by Fade78, last changed 2012-03-30 14:21 by r.david.murray. This issue is now closed.

Messages (2)
msg157133 - (view) Author: (Fade78) Date: 2012-03-30 10:18
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):

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.
msg157137 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-03-30 14:21
The current behavior is how we want the functions to work.  If you want to debate the design, the best forum would probably be python-ideas.
Date User Action Args
2012-03-30 14:21:58r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg157137

resolution: rejected
stage: resolved
2012-03-30 10:18:26Fade78create