[Python-ideas] 'default' keyword argument for max(), min()

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Thu Apr 16 14:14:25 CEST 2009


2009/4/16 Jacob Holm <jh at improva.dk>:

>   # validate args, this TypeError is needed for backwards compatibility
>   if initial is _marker and default is _marker and not args:
>       raise TypeError('min expected 1 arguments, got 0')

I would prefer to raise this error if not args, regardless of initial
and default. This makes the preconditions simpler, and the excluded
cases are never useful (the result value is statically known if the
length of args is statically known, which should always be true to
avoid the case when it has length 1).

It would even make sense to allow initial and default only if args has
length 1. This would again exclude cases where the arguments contain a
statically known redundancy, but this time the preconditions would be
more complicated.

-- 
Marcin Kowalczyk
qrczak at knm.org.pl
http://qrnik.knm.org.pl/~qrczak/



More information about the Python-ideas mailing list