On Wed, Apr 15, 2009 at 3:11 PM, Steven D'Aprano steve@pearwood.info wrote:
On Thu, 16 Apr 2009 04:17:07 am Raymond Hettinger wrote:
[Adam Atlas]
I propose adding a "default" keyword argument to max() and min(), which provides a value to return in the event that an empty iterable is passed.
Could you write your proposal out in pure python so we can see how it interacts with the key-keyword argument and how it works when the number of positional arguments is not one.
Will min(default=0) still return a TypeError? Will min(1, 2, default=0) return 0 or 1? Will min([1,2], default=0) return 1? # different from min([0,1,2])
I would expect the answers should be:
Yes, 1 and 1
but I'd be prepared to be talked into:
No, 1 and 1.
I think it would be counter-intuitive and error-prone if min(iterable, default=0) was different from min(*iterable, default=0), so I'd say no on the first one.
George