[Python-ideas] 'default' keyword argument for max(), min()
spir
denis.spir at free.fr
Fri Apr 17 11:36:03 CEST 2009
Le Thu, 16 Apr 2009 16:07:10 -0700,
"Raymond Hettinger" <python at rcn.com> s'exprima ainsi:
> > As an aside, it would be nice If min/max start raising a more narrow
> > ValueError subtype, say EmptyIterableError, so that hacks such as
> > checking the exception message are not necessary.
>
> I would support that proposal if it would end this effort to
> complexify min/max.
This would be a satisfying solution for me:
try:
result = min(iterable)
except EmptyIterableError:
result = default
Rather pythonic I guess; as well as much simpler and easier to implement.
Denis
------
la vita e estrany
More information about the Python-ideas
mailing list