New submission from Terry J. Reedy <tjre...@udel.edu>:

l=[1,3,2]
l.sort(cmp=lambda x,y:y-x, key=lambda x: x)
print(l)

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@python
components: Documentation
keywords: easy, patch
messages: 132507
nosy: docs@python, terry.reedy
priority: normal
severity: normal
stage: needs patch
status: open
title: Doc list.sort(cmp=,key=) result.
versions: Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11712>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to