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 > the max()/min() functions?
How the Python max and min functions should work has to do with how people want them to work and how people expect them to work. I wouldn't know about most people, but I would have been surprised if min([]) was not an error, and I would have been disappointed if sum([]) was not 0. >From a mathematical point of view, not that that's directly relevant, it doesn't make much sense to me to add that default argument. The max of a set is supposed to be the largest element of that set. If the set is empty there's no such thing. In Python you'd better make sure that S is nonempty before asking for max(S). That's not just Python - in math you need to make certain that S is nonempty and also other conditions before you're allowed to talk about max(S). That's just the way it is. Think about all the previously elected female or black presidents of the US. Which one was the tallest? > Bye, > bearophile -- David C. Ullrich -- http://mail.python.org/mailman/listinfo/python-list