[Python-ideas] 'default' keyword argument for max(), min()
Jared Grubb
jared.grubb at gmail.com
Fri Apr 17 09:33:48 CEST 2009
On 16 Apr 2009, at 16:07, Raymond Hettinger wrote:
>>> The discussion has indeed sidetracked with handling the special
>>> cases,
>>> signature definition and whatnot, but I believe meeting the
>>> conditions
>>> you outlined above is not as rare as their number implies.
>
> This may be a symptom of a particular programming style.
> I've found zero useful examples in scans of the standard library,
> in my own personal code base, or third-party extensions that I use
> regularly.
I did find one example in the stdlib in my scan (Python 2.6.1):
doctest.py:
def _min_indent(self, s):
"Return the minimum indentation of any non-blank line in `s`"
indents = [len(indent) for indent in
self._INDENT_RE.findall(s)]
if len(indents) > 0:
return min(indents)
else:
return 0
Note, however, that I only found 3 examples total that used an
iterable at all (almost all of the cases in the stdlib were of the
form "min(x,y)").
The other two examples were in timeit and urllib2, but each knew the
iterables were non-empty because it had explicitly constructed them in
such a way that they could not be empty.
Jared
More information about the Python-ideas
mailing list