<br><br><div class="gmail_quote">On Sun, Nov 21, 2010 at 1:12 PM, Steven D'Aprano wrote:</div><div class="gmail_quote"><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">


When you have difficulty thinking of a name which clearly and concisely describes what the argument does, that's often a good hint that you are dumping too much responsibility onto the function.<br>
<br>
Having said that, I'd suggest that an appropriate name might be the same name used by sort and friends: key.<br>
</blockquote></div><br><div>I agree with almost everything you wrote, except the suggestion of "key". In sorted et al., the point of key is that you want a certain form used when comparing, but *not* the sorted list that is the final product. That's why you can't just use sorted(name.lower() for name in names) as a substitute for sorted(names, key=str.lower). Compare the following:</div>

<div><br></div><div><div>>>> sorted( [u"MacDonald", u"Macan"])</div><div>[u'MacDonald', u'Macan']</div><div>>>> sorted(s.lower() for s in [u"MacDonald", u"Macan"])</div>

<div>[u'macan', u'macdonald']</div><div>>>> sorted([u"MacDonald", u"Macan"], key=unicode.lower)</div><div>[u'Macan', u'MacDonald']</div></div><div><br></div><div>

None of this applies to any/all, since they just return a True or a False, no matter what kind of iterable input they get. So, key is not a good name, and your earlier analysis of why there shouldn't be another keyword on any/all stands.</div>

<div><br></div><div>-- Carl Johnson</div>