[issue18301] In itertools.chain.from_iterable() there is no cls argument

New submission from py.user: http://docs.python.org/2/library/itertools.html#itertools.chain.from_iterabl...
---------- assignee: docs@python components: Documentation files: issue.diff keywords: patch messages: 191874 nosy: docs@python, py.user priority: normal severity: normal status: open title: In itertools.chain.from_iterable() there is no cls argument type: enhancement versions: Python 3.3, Python 3.4 Added file: http://bugs.python.org/file30702/issue.diff _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18301> _______________________________________

py.user added the comment: http://docs.python.org/3/library/itertools.html#itertools.chain.from_iterabl... ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18301> _______________________________________

R. David Murray added the comment: It is implemented as a classmethod, but the "equivalent" code doesn't need to be part of the class all. I'm not sure what should be done here (say @staticmethod? Leave the decorator off?). We should probably see what Raymond thinks. I lean toward the latter, that's the way it is in the python2 docs, and it doesn't seem to have caused any confusion. ---------- nosy: +r.david.murray, rhettinger _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18301> _______________________________________

Terry J. Reedy added the comment: The 2.7 doc says 'Roughly equivalent to' rather than 'Equivalent to'. The undecorated Python version of from_iterable actually works as an attribute of the Python version of chain: chain.from_iterable = from_iterable. I would just remove the decorator. The entire itertools doc exploits that fact that generator functions are analogous to classes, but it does not work to mix the two in the way that the 3.x chain entry does. ---------- nosy: +terry.reedy _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18301> _______________________________________

Serhiy Storchaka added the comment: Perhaps it should be staticmethod, not classmethod. ---------- nosy: +serhiy.storchaka _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18301> _______________________________________

Serhiy Storchaka added the comment: It should be a classmethod.
The patch LGTM. ---------- assignee: docs@python -> serhiy.storchaka stage: -> commit review _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18301> _______________________________________

Changes by Serhiy Storchaka <storchaka@gmail.com>: ---------- assignee: serhiy.storchaka -> rhettinger _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18301> _______________________________________

Ezio Melotti added the comment:
I would just remove the decorator.
+1 ---------- nosy: +ezio.melotti _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18301> _______________________________________

py.user added the comment:
it should be B ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18301> _______________________________________

py.user added the comment: changed iter(arg) to *arg
---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18301> _______________________________________

Terry J. Reedy added the comment: My counter proposal #18752 is that chain.from_iterable become a deprecated alias for a new function, chain_iterable. With '@classmethod' removed, the current Python equivalent would work for chain_iterable. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18301> _______________________________________

Roundup Robot added the comment: New changeset 29fa1f418796 by Raymond Hettinger in branch '3.3': Issue 18301: The classmethod decorator didn't fit well with the rough-equivalent example code. http://hg.python.org/cpython/rev/29fa1f418796 ---------- nosy: +python-dev _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18301> _______________________________________

Changes by Raymond Hettinger <raymond.hettinger@gmail.com>: ---------- resolution: -> fixed status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18301> _______________________________________

py.user added the comment: http://docs.python.org/3/library/itertools.html#itertools.chain.from_iterabl... ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18301> _______________________________________

R. David Murray added the comment: It is implemented as a classmethod, but the "equivalent" code doesn't need to be part of the class all. I'm not sure what should be done here (say @staticmethod? Leave the decorator off?). We should probably see what Raymond thinks. I lean toward the latter, that's the way it is in the python2 docs, and it doesn't seem to have caused any confusion. ---------- nosy: +r.david.murray, rhettinger _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18301> _______________________________________

Terry J. Reedy added the comment: The 2.7 doc says 'Roughly equivalent to' rather than 'Equivalent to'. The undecorated Python version of from_iterable actually works as an attribute of the Python version of chain: chain.from_iterable = from_iterable. I would just remove the decorator. The entire itertools doc exploits that fact that generator functions are analogous to classes, but it does not work to mix the two in the way that the 3.x chain entry does. ---------- nosy: +terry.reedy _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18301> _______________________________________

Serhiy Storchaka added the comment: Perhaps it should be staticmethod, not classmethod. ---------- nosy: +serhiy.storchaka _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18301> _______________________________________

Serhiy Storchaka added the comment: It should be a classmethod.
The patch LGTM. ---------- assignee: docs@python -> serhiy.storchaka stage: -> commit review _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18301> _______________________________________

Changes by Serhiy Storchaka <storchaka@gmail.com>: ---------- assignee: serhiy.storchaka -> rhettinger _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18301> _______________________________________

Ezio Melotti added the comment:
I would just remove the decorator.
+1 ---------- nosy: +ezio.melotti _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18301> _______________________________________

py.user added the comment:
it should be B ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18301> _______________________________________

py.user added the comment: changed iter(arg) to *arg
---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18301> _______________________________________

Terry J. Reedy added the comment: My counter proposal #18752 is that chain.from_iterable become a deprecated alias for a new function, chain_iterable. With '@classmethod' removed, the current Python equivalent would work for chain_iterable. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18301> _______________________________________

Roundup Robot added the comment: New changeset 29fa1f418796 by Raymond Hettinger in branch '3.3': Issue 18301: The classmethod decorator didn't fit well with the rough-equivalent example code. http://hg.python.org/cpython/rev/29fa1f418796 ---------- nosy: +python-dev _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18301> _______________________________________

Changes by Raymond Hettinger <raymond.hettinger@gmail.com>: ---------- resolution: -> fixed status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18301> _______________________________________
participants (7)
-
Ezio Melotti
-
py.user
-
R. David Murray
-
Raymond Hettinger
-
Roundup Robot
-
Serhiy Storchaka
-
Terry J. Reedy