[New-bugs-announce] [issue11712] Doc list.sort(cmp=,key=) result.
Terry J. Reedy
report at bugs.python.org
Tue Mar 29 21:28:42 CEST 2011
New submission from Terry J. Reedy <tjreedy at udel.edu>:
l.sort(cmp=lambda x,y:y-x, key=lambda x: x)
With CPython 2.7 this
1) could raise an exception like TypeError: conflicting arguments passed;
2) could ignore cmp= and print [1,2,3] on the basis that the new should override the old;
3) does ignore key= and prints [3,2,1] (why does not matter now),
but as near as I can tell, this is not documented.
Suggestion: in 5.6.4. Mutable Sequence Types, in footnote 8, after
"key specifies a function of one argument that is used to extract a comparison key from each list element: key=str.lower. The default value is None."
add "Ignored if *cmp* is also given."
assignee: docs at python
keywords: easy, patch
nosy: docs at python, terry.reedy
stage: needs patch
title: Doc list.sort(cmp=,key=) result.
versions: Python 2.7
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce