List replication operator

MRAB python at mrabarnett.plus.com
Fri May 25 15:19:14 EDT 2018


On 2018-05-25 18:05, Dennis Lee Bieber wrote:
> On Fri, 25 May 2018 15:40:41 +0000 (UTC), Steven D'Aprano
> <steve+comp.lang.python at pearwood.info> declaimed the following:
> 
>>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.
>>
> 
> 	@ requires use of the weaker/shorter "ring finger" on (for me) the
> weaker left hand.
> 
On my UK keyboard, @ is on the right-hand side.

> 	** makes use of the stronger right hand, and longest finger so less a
> stretch. And the timing for the second * isn't that much.
> 
> 
> 	Let me play devil's advocate... and propose a simple change, with no
> new operators...
> 
> 	sl = [] * n	#current behavior
> 	dl = n * []	#deep copy behavior
> 
Both orders are currently valid, and do the same thing, so a change 
would break someone's code.



More information about the Python-list mailing list