Andrew Barnert via Python-ideas wrote:
The usual set-theoretic definition of tuples is just recursively as ordered pairs: () is 0, (a) is a, (a, b) is <a, b>, (a, b, c) is <<a, b>, c>, etc. So, you don’t have to gloss over anything; s1 * s2 * s3 gives you elements ((a, b), c), but those are identical to elements (a, b, c).
But that makes the cartesian product operator non-associative, since s1 * (s2 * s3) would be a set of <a, <b, c>>. I still maintain that *in practice* mathematicians ignore the issue and consider that ((a, b), c), (a, (b, c)) and (a, b, c) are just different ways of writing essentially the same thing. A programming language *could* be designed with a tuple type for which that is literally true, but Python wasn't designed that way. And I don't think it's a problem at all. You can easily write a comprehension that gives you whatever kind of cartesian product you want. -- Greg _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/CBXVP365LCLKKZV4FYB57CXSMW376VXW/ Code of Conduct: http://python.org/psf/codeofconduct/