List replication operator
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Fri May 25 11:40:41 EDT 2018
On Fri, 25 May 2018 22:46:37 +1000, Chris Angelico wrote:
> We've already had a suggestion for [[]]@5 and that should deal with that
> issue. Steven is proposing "multiply by copying" as an alternative to
> "multiply by referencing", so an alternative multiplication operator
> should fit that correctly. Steve, I don't want to speak for you; can you
> confirm or deny acceptance of the matmul operator as a better spelling?
I thought that ** would be less controversial than @ since that's much
newer. Silly me.
Personally, I don't care much either way. Probably a microscopic
preference for @ over ** since it is shorter, but not enough to matter.
The usefulness of * with lists is seriously compromised by the inability
to copy mutable items in the list. Consequently, it is an on-going gotcha
and pain point.
On the other hand, it is arguable that what we really need is a standard
function to return an N-dimensional array/list:
# return a 3x4x5x6 4-D list initialised to all zeroes
arr = list.dimensions(3, 4, 5, 6, initial=0.0)
--
Steve
More information about the Python-list
mailing list