On 10/12/2013 10:35 AM, Steven D'Aprano wrote:I agree that backwards compatibility should be kept, but the current behaviour of itertools.permutations is (IMHO) surprising.
If you want a unique_permutations generator, that's a reasonable
request. If you insist on changing permutations, that's unreasonable,
firstly because the current behaviour is correct, and secondly because
backwards compatibility would constrain it to keep the existing
behaviour even if it were wrong.
So here are my 2c: Until I tried it myself, I was sure that it will be like the corresponding permutations functions in Sage:
sage: list(Permutations("aba"))
[['a', 'a', 'b'], ['a', 'b', 'a'], ['b', 'a', 'a']]
or Mathematica: http://www.wolframalpha.com/input/?i=permutations+of+{a%2C+b%2C+a}
Currently the docstring of itertools.permutations just says "Return successive r-length permutations of elements in the iterable", without telling what happens with input of repeated elements. The full doc in the reference manual is better in that regard, but I think at least one example with repeated elements would be nice.
Regards,
TB
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
--
--- You received this message because you are subscribed to a topic in the Google Groups "python-ideas" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python-ideas/dDttJfkyu2k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python-ideas+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.