Some thougts on cartesian products

Alex Martelli aleax at mail.comcast.net
Sun Jan 22 17:50:23 CET 2006


Kay Schluehr <kay.schluehr at gmx.net> wrote:
   ...
> > >> range(3)**2
> > [(0,0), (0,1), (0,2), (1,0), (1,1), (1,2), (2,0), (2,1), (2,2)]
   ...
> But why isn't this interpreted as [0, 1, 4] like it is in Mathematica?

Since range(3)*2 is [0, 1, 2, 0, 1, 2], it would be horribly, painfully
inconsistent if **2 was interpreted as "square each item".


Alex



More information about the Python-list mailing list