This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: itertools.tee() can't accept keyword arguments
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: BreamoreBoy, christian.heimes, py.user, rhettinger, terry.reedy
Priority: low Keywords:

Created on 2013-06-26 18:08 by py.user, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (10)
msg191912 - (view) Author: py.user (py.user) * Date: 2013-06-26 18:08
>>> import itertools
>>> itertools.tee('x', n=2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: tee() takes no keyword arguments
>>>
msg191916 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2013-06-26 19:26
A bunch builtin types and functions don't accept keyword args. kwargs make code slightly more complexity and a tiny bit slower.
msg191927 - (view) Author: py.user (py.user) * Date: 2013-06-27 01:23
tee() docs describe n as a keyword
msg207089 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2013-12-30 00:19
Why has this been closed?  I've just run into exactly the same problem.  It states here http://docs.python.org/3/library/itertools.html#itertools.tee "itertools.tee(iterable, n=2) - Return n independent iterators from a single iterable."
msg207090 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2013-12-30 00:51
The docs for tee are the same going right back to its introduction in 2.4.  The itertools count function takes start and step keywords, why can't tee take a keyword as it's documented to?
msg207091 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2013-12-30 05:08
It's just the docs that need changing to clarify the situation as (say) a,b,c = tee(range, 3) works perfectly.  Sorry I didn't have the foresight to check this before :(
msg207102 - (view) Author: py.user (py.user) * Date: 2013-12-30 18:52
for example
http://docs.python.org/3/library/itertools.html#itertools.permutations

has same description and it's a keyword

compare
"itertools.tee(iterable, n=2)"
"itertools.permutations(iterable, r=None)"


>>> itertools.permutations('abc')
<itertools.permutations object at 0x7ff563b17230>
>>> itertools.permutations('abc', r=2)
<itertools.permutations object at 0x7ff563b17290>
>>> 
>>> 
>>> itertools.tee('abc')
(<itertools._tee object at 0x7ff563a995f0>, <itertools._tee object at 0x7ff563a99638>)
>>> itertools.tee('abc', n=2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: tee() takes no keyword arguments
>>>
msg207258 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-01-03 23:57
It is an unfortunate (to my mind) but true fact that the docs do not indicate which functions are coded in C and for such functions, whether args passable by position can also be passed by name. If one wishes to pass by name, one simply has to experiment. The problem is possibly a bit worse for itertools because its docs have 'equivalent' Python code that is not quite equivalent for position-only C parameters. Solutions would be a fit topic for python-ideas list.

The tee docs do not describe 'n' as a keyword. They only indicate its default value, which is a different issue altogether.

The word 'keyword' only appears in the 'product' entry to describe the 'repeat' parameter. It there means 'pass by name only', as product() takes an indefinite number of positional iterables, so that a repeat value cannot be passed by position.


'user': please do not play with the Status: value. This is a good way to make yourself unpopular with developers. If a developer 'closes' an issue and you wish it 'reopened', ask and explain, and be willing for the request to be ignored or rejected.
msg207265 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-01-04 03:56
From the glossary

Quote

keyword argument: an argument preceded by an identifier (e.g. name=) in a function call or passed as a value in a dictionary preceded by **. For example, 3 and 5 are both keyword arguments in the following calls to complex():

complex(real=3, imag=5)
complex(**{'real': 3, 'imag': 5})

End Quote

From itertools docs "itertools.tee(iterable, n=2) Return n independent iterators from a single iterable", so what is this if it's not a keyword argument?  Surely all that's needed in this case is for the docs to read "itertools.tee(iterable[, n]) Return n independent iterators from a single iterable where n defaults to 2"
msg207270 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-01-04 07:30
'name=val' in a signature (not a call) merely indicates that name has a default. The 2.x use of [] to indicate the the parameter with a default is optional was dropped as redundant in the 3.x docs. The 2.x; tee doc has [, n=2]. The 3.x doc is correctly according to the 3.x doc standard.
History
Date User Action Args
2022-04-11 14:57:47adminsetgithub: 62510
2014-01-04 07:30:00terry.reedysetmessages: + msg207270
2014-01-04 03:56:31BreamoreBoysetmessages: + msg207265
2014-01-03 23:57:07terry.reedysetstatus: pending -> closed

nosy: + terry.reedy
messages: + msg207258

stage: resolved
2013-12-30 19:06:03py.usersetstatus: open -> pending
2013-12-30 18:52:22py.usersetstatus: pending -> open

messages: + msg207102
2013-12-30 18:38:37py.usersetstatus: closed -> pending
2013-12-30 05:08:06BreamoreBoysetmessages: + msg207091
components: + Documentation, - Library (Lib)
versions: + Python 2.7
2013-12-30 00:51:27BreamoreBoysetmessages: + msg207090
2013-12-30 00:19:14BreamoreBoysetnosy: + BreamoreBoy
messages: + msg207089
2013-06-27 02:42:22rhettingersetstatus: open -> closed
resolution: rejected
2013-06-27 01:23:43py.usersetmessages: + msg191927
2013-06-26 19:26:35christian.heimessetpriority: normal -> low

nosy: + rhettinger, christian.heimes
messages: + msg191916

assignee: rhettinger
2013-06-26 18:08:11py.usercreate