Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

itertools.permutations docstring is misleading #46788

Closed
devdanzin mannequin opened this issue Apr 2, 2008 · 2 comments
Closed

itertools.permutations docstring is misleading #46788

devdanzin mannequin opened this issue Apr 2, 2008 · 2 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@devdanzin
Copy link
Mannequin

devdanzin mannequin commented Apr 2, 2008

BPO 2536
Nosy @birkenfeld, @rhettinger, @devdanzin

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2008-06-10.12:48:35.753>
created_at = <Date 2008-04-02.10:48:02.519>
labels = ['type-bug', 'library']
title = 'itertools.permutations docstring is misleading'
updated_at = <Date 2008-06-10.12:48:35.652>
user = 'https://github.com/devdanzin'

bugs.python.org fields:

activity = <Date 2008-06-10.12:48:35.652>
actor = 'georg.brandl'
assignee = 'none'
closed = True
closed_date = <Date 2008-06-10.12:48:35.753>
closer = 'georg.brandl'
components = ['Library (Lib)']
creation = <Date 2008-04-02.10:48:02.519>
creator = 'ajaksu2'
dependencies = []
files = []
hgrepos = []
issue_num = 2536
keywords = []
message_count = 2.0
messages = ['64846', '67902']
nosy_count = 3.0
nosy_names = ['georg.brandl', 'rhettinger', 'ajaksu2']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue2536'
versions = ['Python 2.6']

@devdanzin
Copy link
Mannequin Author

devdanzin mannequin commented Apr 2, 2008

Currently, Modules/itertoolsmodule.c lines 2471-2475 are:

PyDoc_STRVAR(permutations_doc,
"permutations(iterables[, r]) --> permutations object\n\
\n\
Return successive r-length permutations of elements in the iterable.\n\n\
permutations(range(4), 3) --> (0,1,2), (0,1,3), (0,2,3), (1,2,3)");

but that describes behavior of itertools.combinations. The correct
example is in a comment on line 2254 of the same file:

'permutations(range(3), 2) --> (0,1) (0,2) (1,0) (1,2) (2,0) (2,1)'

I used "misleading" instead of "wrong" because the current docstring
does show a subset of the real output and could be said to be
incomplete. If that is the case, I suggest being explicit:

'permutations(range(4), 3) --> (0, 1, 2), (0, 1, 3), (0, 2, 1), (0, 2,
3), (0, 3, 1), (0, 3, 2), (1, 0, 2), (1, 0, 3), (1, 2, 0), (1, 2, 3),
(1, 3, 0), (1, 3, 2), (2, 0, 1), (2, 0, 3), (2, 1, 0), (2, 1, 3), (2, 3,
0), (2, 3, 1), (3, 0, 1), (3, 0, 2), (3, 1, 0), (3, 1, 2), (3, 2, 0),
(3, 2, 1)'

@devdanzin devdanzin mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Apr 2, 2008
@birkenfeld
Copy link
Member

Fixed in r64067.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant