List replication operator

Cameron Simpson cs at cskk.id.au
Fri May 25 01:26:53 EDT 2018


On 25May2018 02:32, Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:
>On Fri, 25 May 2018 08:02:38 +1000, Cameron Simpson wrote:
>
>> I'm also against the "**" spelling I find, for much the same reasons
>> that people oppose allowing "=" and "==" in the same syntactic location:
>> they're easy to get wrong through typing inaccuracy.
>
>Do you often write
>
>   y = 2**x
>
>when you meant 2*x?

Well, no, but in that context they mean very different things. Your * vs ** 
mean very similar things.

>In any case, I'm not wedded to the ** spelling, MRAB's suggestion of @
>would work for me too.

Hmm, perhaps.

I rarely use the * list replicator myself (though I used it just the other day 
to prefill a list with None). What's your commonest use case? And also, what's 
you're commonest use case which is prone the the issue a shallow copy would 
help with?

Cheers,
Cameron Simpson <cs at cskk.id.au>



More information about the Python-list mailing list