[Python-ideas] Extremely weird itertools.permutations
Neil Girdhar
mistersheik at gmail.com
Sat Oct 12 10:20:24 CEST 2013
+1
On Sat, Oct 12, 2013 at 4:18 AM, TB <bauertomer at gmail.com> wrote:
> On 10/12/2013 10:35 AM, Steven D'Aprano wrote:
>
>> 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.
>>
>> I agree that backwards compatibility should be kept, but the current
> behaviour of itertools.permutations is (IMHO) surprising.
>
> 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}<http://www.wolframalpha.com/input/?i=permutations+of+%7Ba%2C+b%2C+a%7D>
>
> 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 at python.org
> https://mail.python.org/**mailman/listinfo/python-ideas<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<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<python-ideas%2Bunsubscribe at googlegroups.com>
> .
> For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
> .
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20131012/710b24c5/attachment.html>
More information about the Python-ideas
mailing list