[Python-ideas] Support multiplication for sets

Calvin Spealman ironfroggy at gmail.com
Fri Oct 7 17:55:32 CEST 2011


On Fri, Oct 7, 2011 at 6:37 AM, Jakob Bowyer <jkbbwr at gmail.com> wrote:
>
> There is that but from a math point of view the syntax a * b does make sence.
> Its slightly clearer and makes more sense to **people from outside of a programming background**.

(emphasis added)

These are not the only people writing and reading code, and decisions
about syntax should favor improving the readability
for coders across the board, not simply a single subset of them.

>
> On Fri, Oct 7, 2011 at 11:35 AM, Paul Moore <p.f.moore at gmail.com> wrote:
>>
>> On 7 October 2011 11:24, Jakob Bowyer <jkbbwr at gmail.com> wrote:
>> > Looking at this from a Math background, it seems that it would be nice for
>> > the set type to support multiplication. This would allow for the
>> > multiplication of sets to produce Cartesian products giving every single
>> > permutation. This would make set usage more intuitive for example;
>> > (assuming python3)
>> >
>>
>> itertools.product does what you want already.
>>
>> >>> a = set((1,2,3))
>> >>> b = set((4,5,6))
>> >>> set(itertools.product(a,b))
>> {(2, 6), (1, 4), (1, 5), (1, 6), (3, 6), (2, 5), (3, 4), (2, 4), (3, 5)}
>>
>> I don't think an operator form is sufficiently valuable when the
>> functionality is available and clear enough already.
>>
>> Paul.
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>



--
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy



More information about the Python-ideas mailing list