[Python-ideas] Proposal to change List Sequence Repetition (*) so it is not useless for Mutable Objects

Sven R. Kunze srkunze at mail.de
Tue May 31 08:55:04 EDT 2016

On 31.05.2016 13:39, Lorenz wrote:
> Hi Matthew,
> I agree that when I was starting out with python this tripped me up a couple
> of times but Marc-Andre pointed out it is not necessarily easy to solve in a
> generic way.

I can only agree here. Even today, despite knowing the fact, it's 
causing some headaches in some cases.

However, I think that's the reason why it's not so easy to do in a 
general manner.

Maybe, somebody has a good idea how to.


> As a point of reference, I currently tend to do this via generators
>    arr = list(Foo() for i in range(5))
> or list comprehensions
>    arr = [Foo() for i in range(5)]
> note that this works for the mutable and immutable case.
> Kind Regards,
> Lorenz

More information about the Python-ideas mailing list