[issue19423] permutations len issue

2013-10-28 Thread Evgeny Luttsev

New submission from Evgeny Luttsev:

Code:
n = 2
perms = permutations(range(n), n)
if list(perms) == [(0, 1), (1, 0)]:
print(==)
print(len(list(perms)):, len(list(perms)))

Result:
==
len(list(perms)): 0 # SHOULD BE 2

--
components: Library (Lib)
messages: 201556
nosy: DSblizzard
priority: normal
severity: normal
status: open
title: permutations len issue
type: behavior
versions: Python 2.6, Python 3.1

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



[issue19423] permutations len issue

2013-10-28 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

permutations() returns a generator.
If you consume it with list(), the second time will return the empty list.

Use list(permutations(...)) if you plan to use the result multiple times.

--
nosy: +amaury.forgeotdarc
resolution:  - invalid
status: open - closed

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