List replication operator

Chris Angelico rosuav at gmail.com
Fri May 25 08:46:37 EDT 2018


On Fri, May 25, 2018 at 10:36 PM, bartc <bc at freeuk.com> wrote:
> On 24/05/2018 19:17, Steven D'Aprano wrote:
>
>> But what do people think about proposing a new list replication with copy
>> operator?
>>
>>      [[]]**5
>>
>> would return a new list consisting of five shallow copies of the inner
>> list.
>>
>> Thoughts?
>
>
> Choice of ** doesn't seem right for a start, as it suggests it should mean
> []*[]*[]*[]*[], which it doesn't. (Apparently []*2 /is/ the same as []+[].)
>

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?

ChrisA



More information about the Python-list mailing list