[issue20407] heapq.nsmallest and heapq.nlargest don't accept a "key" parameter

2014-01-27 Thread Georg Brandl
Georg Brandl added the comment: I see, there are two "def nsmallest" in heapq.py. Tricky! -- ___ Python tracker ___ ___ Python-bugs-l

[issue20407] heapq.nsmallest and heapq.nlargest don't accept a "key" parameter

2014-01-27 Thread Raymond Hettinger
Raymond Hettinger added the comment: The docs are correct as-is. This is a documented and tested behavior. >>> from heapq import nsmallest >>> list(nsmallest(3, ['larry', 'georg', 'raymond', 'guido', 'tim'], key=len)) ['tim', 'larry', 'georg'] The C implementation doesn't have a k

[issue20407] heapq.nsmallest and heapq.nlargest don't accept a "key" parameter

2014-01-27 Thread Georg Brandl
Georg Brandl added the comment: Yes. Probably someone wished they would implement it :) -- ___ Python tracker ___ ___ Python-bugs-lis

[issue20407] heapq.nsmallest and heapq.nlargest don't accept a "key" parameter

2014-01-27 Thread Larry Hastings
Changes by Larry Hastings : -- nosy: +georg.brandl ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail

[issue20407] heapq.nsmallest and heapq.nlargest don't accept a "key" parameter

2014-01-27 Thread Larry Hastings
New submission from Larry Hastings: The documentation for heapq.nsmallest and heapq.nlargest: http://docs.python.org/3.3/library/heapq.html#heapq.nlargest claim that they accept three arguments: n, iterable, and key=None. In fact, the implementations of both these functions only accept two pa