I support PEP 326

Andrew Koenig ark at acm.org
Fri Jan 23 15:46:53 CET 2004

> Calling min with no arguments need not be the same as calling it with an
> empty sequence argument. That is not necessarily an argument for making
> the empty function call return something arguably strange...

I agree with you that it's strange, but it's right.  It might interest you
to know that APL has behaved the same way for more than 35 years.  In APL,
the usual way of obtaining the largest positive value is to ask for the
lowest element of an empty sequence.

In Python, if you give min or max a single argument, it is assumed to be a
sequence, and if that sequence is empty, you get an exception.  If you give
it more than one argument, those arguments are treated as elements of a
sequence, and you get an exception if there are no arguments (i.e. if the
sequence is empty).

Therefore, if min([]) were to return Max (which, although surprising, I
still think is reasonable), then min() should also return Max.

More information about the Python-list mailing list