[Python-ideas] Support multiplication for sets
Greg Ewing
greg.ewing at canterbury.ac.nz
Sat Oct 8 05:58:28 CEST 2011
Nick Coghlan wrote:
> I expect what you actually intended here was:
>
> cp = product(seta, setb|setc, setd&sete)
>
> If you actually did want two distinct cartesian products, then the two
> line version is significantly easier to read:
>
> cp_a = product(setb|setc, setd&sete)
> cp_b = product(seta, cp_a)
This is another area where the comprehension syntax is very
useful. It lets you specify exactly what structure you want
for the results in a very natural and readable way.
--
Greg
More information about the Python-ideas
mailing list