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 "", line 1, in TypeError: tee() takes no keyword arguments >>> |
|
|
msg191916 - (view) |
Author: Christian Heimes (christian.heimes) *  |
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 "", line 1, in TypeError: tee() takes no keyword arguments >>> |
|
|
msg207258 - (view) |
Author: Terry J. Reedy (terry.reedy) *  |
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) *  |
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. |
|
|