[issue21771] name of 2nd parameter to itertools.groupby()

2014-06-15 Thread Uwe Kleine-König

New submission from Uwe Kleine-König:

The name of the 2nd parameter to itertools.groupby() is documented 
inconsitently. Sometimes it's key, sometimes keyfunc. The code actually 
uses key, so I adapted all occurences I found to key.

 from itertools import groupby
 groupby.__doc__
'groupby(iterable[, keyfunc]) - create an iterator which returns\n(key, 
sub-iterator) grouped by each value of key(value).\n'

 groupby([], keyfunc=lambda x: x)
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: 'keyfunc' is an invalid keyword argument for this function

 groupby([], key=lambda x: x)
itertools.groupby object at 0x7fee025d2048

--
assignee: docs@python
components: Documentation
files: groupby-keyfunc.patch
keywords: patch
messages: 220639
nosy: docs@python, ukl
priority: normal
severity: normal
status: open
title: name of 2nd parameter to itertools.groupby()
type: enhancement
versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5
Added file: http://bugs.python.org/file35645/groupby-keyfunc.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21771
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21771] name of 2nd parameter to itertools.groupby()

2014-06-15 Thread Ned Deily

Changes by Ned Deily n...@acm.org:


--
nosy: +rhettinger

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21771
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21771] name of 2nd parameter to itertools.groupby()

2014-06-15 Thread Raymond Hettinger

Raymond Hettinger added the comment:

There is a bit an inconsistency but it is more helpful than harmful most of the 
time.  The glossary defines a key-function which is used in a number of places 
such such as sorted(), min(), nsmallest() and others.  In all those cases, the 
parameter for the key-function is *key*.

It might feel more consistent to call it key everywhere, but that leaves 
out the explanation that *key* represents a key-function.

The other issue is that groupby() returns a (key, sub-iterator) pair where 
key is the result of key-function, not the key itself.

What we have now is imperfect but it does a reasonably good job helping people 
understand what the function does.  IMO, changing it to be key would make the 
docs less intelligible.

Thank you for the patch, but I'm going to pass on it.

--
resolution:  - rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21771
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com