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

Jacob Holm jh at improva.dk
Thu Apr 16 14:27:23 CEST 2009

Marcin 'Qrczak' Kowalczyk wrote:
> 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).

I agree.

> 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.

It would complicate the preconditions without much gain, but I don't 
really care either way.

- Jacob

More information about the Python-ideas mailing list