<div class="gmail_quote">On Fri, Oct 7, 2011 at 6:24 AM, Jakob Bowyer <span dir="ltr"><<a href="mailto:jkbbwr@gmail.com">jkbbwr@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
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;<div>
(assuming python3)<br><div><br></div><div>a = set(["amy", "martin"])</div><div>b = set(["smith", "jones", "john"])</div><div>c = a * b</div><div>print(c)</div></div><div>
<br>
</div><div><div>set([('john', 'jones'),</div><div> ('john', 'martin'),</div><div> ('jones', 'john'),</div><div> ('martin', 'amy'),</div></div><div>
....])</div><div><br></div><div>This could be really easily achieved by giving a __mul__ method for sets. Currently trying to multiply sets gives a TypeError. Anyone got any views on this? Or am I barking up the wrong tree and saying something stupid.</div>
<br></blockquote></div><br>This idea might be aesthetically pleasing from a mathematical viewpoint, but it does not help people write better programs. It does not provide anything better than the status quo. In fact, it adds an obscure behavior that needs to be maintained, taught, and understood, making Python ever-so-slightly worse.<br>
<br>-1<br><br>Mike<br>