[Python-ideas] Extremely weird itertools.permutations
Neil Girdhar
mistersheik at gmail.com
Fri Oct 11 20:50:00 CEST 2013
Note that if permutations is made to return only unique permutations, the
behaviour of defining unique elements by index can be recovered using:
([it[index] for index in indexes] for indexes in
itertools.permutations(range(len(it))))
On Friday, October 11, 2013 2:38:33 PM UTC-4, Neil Girdhar wrote:
>
> "It is universally agreed that a list of n distinct symbols has n!
> permutations. However, when the symbols are not distinct, the most common
> convention, in mathematics and elsewhere, seems to be to count only
> distinct permutations." —
> http://stackoverflow.com/questions/6534430/why-does-pythons-itertools-permutations-contain-duplicates-when-the-original
> .
>
>
> Should we consider fixing itertools.permutations and to output only unique
> permutations (if possible, although I realize that would break code). It is
> completely non-obvious to have permutations returning duplicates. For a
> non-breaking compromise what about adding a flag?
>
> Best,
> Neil
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20131011/3afa3f15/attachment-0001.html>
More information about the Python-ideas
mailing list