[Python-ideas] Support multiplication for sets

Jakob Bowyer jkbbwr at gmail.com
Fri Oct 7 12:37:46 CEST 2011


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.

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.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20111007/6f9862f9/attachment.html>


More information about the Python-ideas mailing list