<div class="gmail_quote">On Wed, Nov 30, 2011 at 9:30 AM, Jakob Bowyer <span dir="ltr"><<a href="mailto:jkbbwr@gmail.com" target="_blank">jkbbwr@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I just had something pointed out to me in #python that min and max accept *args, I know for a fact that any and all only use a single iterable password.<br>Shouldn't we allow either one of the two ideas?<div><br></div>
<div>Either max/min take only iterable arguments.</div><div>OR</div><div>Allow any/all to use *args</div></blockquote><div><br>This seems consistency for consistency's sake, not for any particularly good reason. min/max are quite different from any/all, e.g. min() or max() without arguments makes no sense, while any() / all() on an empty list has a perfectly fine meaning (False / True, respectively).<br>
<br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>In the second case this becomes legal</div><div><br></div><div>any(1 in a, 2 in b, 3 in c)</div>
</blockquote><div><br>But that's just alternative syntax for<br><br> 1 in a or 2 in b or 3 in c<br><br>except that it doesn't have shortcut semantics, so it would be an attractive nuisance. Note that any() / all() *do* have shortcut semantics, in the sense that they stop iterating over the argument iterable as soon as they have an answer that forces the outcome (True in the case of any(), False in the case of all()). This doesn't apply to min() or max() -- you always have to look at all values before you can decide on which is the largest. (It would be different if we had a general infinity, but we don't -- only floating point numbers support infinity).<br>
<br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div></div><div>In the first case this becomes illegal</div><div>max(1,2,3,4,5)</div>
</blockquote><div><br>Which I presume is rarely needed but if necessary can easily be written as max((1, 2, 3, 4, 5)). <br></div></div><br>-- <br>--Guido van Rossum (<a href="http://python.org/%7Eguido" target="_blank">python.org/~guido</a>)<br>